Got Judged as someone 'who can't code' for Not Knowing Tries—Am I Really That Bad?

Posted by Next-Builder-2047@reddit | learnprogramming | View on Reddit | 194 comments

I recently had an interview for a frontend role for a startup where the interviewer first asked me to find the Longest Common Subsequence (LCS). I started with a brute-force recursive approach, explaining the take/not-take method. He immediately asked why I was using recursion instead of an iterative approach. I agreed that it could also be done iteratively using DP, but before I could proceed, he changed the question entirely.

He then asked me to solve a 'subarray' version instead of a 'subsequence' one. Before I could properly think through that, he changed the question again to finding the Longest Common Prefix, saying, 'Let me make it simpler for you,' which felt like he was underestimating my thinking.

For the common prefix question, I implemented a solution that iteratively compares each string and updates the prefix, making it O(N * M). He asked me to optimize it and I said we could go for sorting the array itself and get from the first one as our common one. The interviewer dismissed it as inefficient and expected me to optimize it without sorting. I later realized that a Trie could be used, but I wasn’t familiar with it at the time.

Later, he asked UI/JavaScript-related questions, which I answered perfectly. However, he still told me that I 'can't code well' just because I couldn't optimize that one problem. He even suggested a part-time role, saying that as a fresher, I shouldn’t worry too much about compensation.

I’m feeling disheartened. I know I’m good at frontend development, but struggling with one specific DSA problem made him judge my entire ability. Does not knowing Tries or missing an optimization mean I'm a bad frontend engineer? How should I deal with such feedback?