Short Problem Definition:
Tie adjacent ropes to achieve the maximum number of ropes of length >= K.
expected worst-case time complexity is O(N);
expected worst-case space complexity is O(N)
I am a bit skeptical about the correctness of my solution. It gets 100/100 through…
def solution(K, A): cnt = 0 current = 0 for part in A: current += part if current >= K: cnt +=1 current = 0 return cnt
If you enjoyed this post, then make sure you subscribe to my Newsletter and/or Feed.