Often, being deep into the problem and discovering that you are solving the wrong problem or made some incorrect assumptions can completely block creative thinking.
- The interviewer might be able to stop you early on.
- It's easy to refer back to when you get lost.
- What do you know and not know?
Ask what are the input and output types are and their semantics.
- What are the inputs and outputs?
- What is their purpose?
- Does the algoritm return the result or the index where the result occurs?
Remove unknowns to cliarify the problem and edge cases. The interviewer could put additional constraits on the input to simplify the solution.
Example: inputs cannot be null.
- Can any of the values be null?
- Can a list be empty?
- Can numbers be negative?
Create your own tests cases on top of the provided ones. If no test cases were provided, ask for some.
- Try to create tests cases that would break the naive solution.
- Potentially ask the interviewer for test cases that show advanced scenarios.