The first step for any data structures and algorithms (DSA) problem is to clarify the problem. This means understanding exactly what the input and expected output are.
A common failure mode for candidates is that they will jump straight into coding, not doing this step. This leads to them wasting a lot of time writing code that isn't actually relevant.
Often times in an interview, you will get a purposefully ambiguous problem - This happens with Big Tech a lot. The goal is get signal on the candidate's communication abilities.
Clarifying the problem can help you a lot as it's very possible that the problem's scope is much more limited than you initially thought.