Answer: BETTER Hiring | Off-Campus OA (2025) | Find All Numbers Disappeared in an Array

Answer · Posted Jun 2026

Approach Since every number lies in the range 1 to n, use each value as an index. Traverse the array: For every number, mark its corresponding index as visited by making the value at that index negative. Traverse the array again: If any value is still positive, its index + 1 was never visited. Add it to the answer. This approach avoids using any extra array. Strategy Use the input array itself for marking visited numbers. Convert values to negative ...

The full answer & interview discussion are available to premium members.

Log in Create a free account