The interviewer was nice but ended up confusing me significantly. The expected output seemed to be different from what he initially communicated, which threw off my thought process. When I pointed out the discrepancy, he acknowledged that he was also confused, which cost us about 20-25 minutes.
I was interviewing for a frontend position, and I understand that some people might disagree with what I'm about to say. The problem given was a variation of the Knapsack problem. While data structures and algorithms (DSA) have become standard in interview processes, I don't see why the Knapsack problem is relevant for frontend interviews. In my experience, complex optimization or calculations are rarely part of frontend work.
Before we started, the interviewer mentioned that the problem was small, but small code doesn't necessarily mean it's easy. With some hints, I realized it was a dynamic programming (DP) problem, but the interviewer was set on a specific solution he had in mind and didn't allow me to explore alternative approaches. After the interview, I checked and found that the solution was indeed a DP implementation. However, I still don't understand what he expected from me.
I ended up implementing a brute-force solution using backtracking, but he said he couldn't follow my code. At that point, I wanted to tell him that there are often multiple ways to solve a problem and different ways to write code. Given the current tough job market, the experience left me feeling quite disheartened.