Question DSA-ARR-0071
HardHow can you find the subarray with sum 0 in O(n) time?
- A.
Try all pairs
- B.
Sort and use two pointers
- C.
Sign up free to see the answer and a step-by-step explanation.
Popular companies
Prepare company by company
Hiring pattern, syllabus, past questions and mocks for each company.
All companiesPractice by subject
Arrays question
How can you find the subarray with sum 0 in O(n) time?
Try all pairs
Sort and use two pointers
Sign up free to see the answer and a step-by-step explanation.
Binary search
Track prefix sums in a hash set; a repeated prefix sum means the elements between sum to 0