Find the minimum removals from either end that sum to exactly x.
Unlock detailed company stats for this questionUpgrade
Given an array readings and an integer x, remove elements from either end of the array so that the removed values sum to exactly x, using the minimum number of removals.
Examples:
- readings = [1,1,4,2,3], x = 5 -> 2 (remove 3, then 2)
- readings = [3,2,20,1,1,3], x = 10 -> 1
Constraints: 1 <= readings.length <= 10^5, 1 <= readings[i] <= 10^4, 1 <= x <= 10^9.
Expect follow-ups like
- What are the time and space complexity of your solution?
Format · DSA problem-solving round.
Community answers
No answers contributed by the community yet.
Related questions
Find the minimum moves to reach target n, taking exactly i steps in move i.Find the minimum removals so the largest element is at most twice the smallest.Find a path from S to T that maximizes the minimum distance to the cat C.Related courses

Course

Course
Course
