#3781
Maximum Score After Binary Swaps
expert · 1075 · lc medium +32 · 35% accepted · 74 likes · top 13%
Description
Given an integer array nums of length n and a binary string s of the same length, where each position with s[i] = '1' contributes nums[i] to your score, and you may swap adjacent characters '0' and '1' any number of times, return the maximum score achievable.
Code
1
2
3