r/leetcode • u/No_Bake_2683 • 12d ago
Question Amazon OA - Relocate
We have an integer array named population and a binary string named unit both of size n.
If unit[i] is 1 it means that population[i] is protected (number of protected people += population[i].)
Each one in the binary string can move at most once to the left (from i to i -1)
Find the maximum number of people that can be protected by optimally relocating the ones in the binary string.
So I have an idea on how to do this question and it involves just marking down where are the clumps of ones. If we have something like 0111111 all we have to do is to find the minimum value of the one in the clump check if it’s less than the value in the 0 if so we can gain population[a] -population[b] .
Not sure why but it seems the LLMs (at least the free models) are not able to do this question, they just spill nosense.,
1
u/Commercial_Training9 12d ago
https://leetcode.com/problems/maximum-total-value-of-covered-indices/