Fewest Bounded Pieces — Solution & Editorial
Greedy left-to-right: keep extending the current piece while its sum stays ≤ K; start a new piece when it would overflow. Any element > K makes it impossible.
Complexity: O(N)
Greedy left-to-right: keep extending the current piece while its sum stays ≤ K; start a new piece when it would overflow. Any element > K makes it impossible.
Complexity: O(N)