2 DSA questions, both are leetcode Medium
I have 4yrs+ Exp. I have restarted doing DSA since April. Have been getting very few callbacks(eventhough tier-1 college ig it doesnt matter much now). This is the 5th company I gave interview. Interviewer approached.
To be frank, I struggled once I started because I never did probability-based questions before.
I first gave a brute-force solution using recursion, then later tried to come up with an optimized approach.
While implementing the brute-force solution, I realized that Dynamic Programming (DP) could optimize it.
So, I derived the recurrence relation, and the interviewer agreed with my approach.
As time was running out, I wrote the pseudo-code for the problem.
However, I think I messed up when he asked about the space-optimized solution.
I mentioned that we could use prev and curr pointers but couldn’t include that in the pseudo-code — which was a mistake.
🕒 Time taken: 45 minutes
Since time was short, I started with a brute-force solution, which the interviewer asked me to optimize.
I thought hard for a couple of minutes and came up with a two-pointer solution.
However, I made a mistake — my logic was incorrect.
The interviewer then gave me a hint, and I was able to complete the solution correctly.
🕒 Time taken: 15 minutes
Rejected
I had little bit hope because I could complete the correct solutions explained things iteratively but I guess I have taken too many hints from the interviewer & couldnt complete correct code.
Its disheartning to hear it but yeah will keep on grinding!