ie, a tree-related problem has 3 ways to solve, time complexity is same across. Space complexity is such that recursive dfs is worst due to stackoverflow risk, followed by iterative DFS and then iterative BFS. 1) iterative DFS 2) iterative BFS 3) recursive dfs Now, if you already gave a working iterative DFS solution, how likely is the interviewer to ask you to 'solve it another way', even though any other way is not any more efficient? I can see if you give a recursive dfs solution, you may be asked 'can you do it iteratively to eliminate stack overflow risk', but vice versa?
Unlikely, but not impossible. you will spend most of that 35 mins working on logic and coding and if you finish early then you will get another question.
Maybe you thought there's no other way, but in fact the problem could be solved using DP and interviewer want you to figure it out.
lmao we're not mind readers. Maybe the interviewer will ask that, maybe they won't because they want to move on to another question who tf knows? Just be able to cover all your bases while you're studying, but trying to strategize like this is stupid.