Scarlet Serenade

LeetCode Solutions | 1001 - 1100

1004. Max Consecutive Ones III

sliding window

1058. Minimize Rounding Error to Meet Target

memoized recursion || dp


首先判断是否是可行的:sum(prices.map(floor)) in target-length..=target. If so, we can switch the numbers from floored to ceiled one by one until we reach the target.

In order to minimize the rounding error, we can determine the optimal order to switch the elements. Ideally, the closer the value to ceiling, the sooner it should be switched.

1086. High Five

pq of fixed size


partial sort

1099. Two Sum Less Than K

sort & two pointers


sort & fix the left one, binary search on the right part

1133. Largest Unique Number

hashmap


sort