Anyone think this problem should be hard? To me it is really unnatural to get the word count first and every time when seeing the new character go backward of current solution to check if they could be at later. Sure, given algorithm, I could understand it and see why it works, but I doubt I could come up such a solution in an interview. Anyone with me? Or how people could think of this direction without any hints?
Thanks for your feedback, I agree it is a tricky question. I have just changed the difficulty to hard.
@aack I agree that it is hard to find a solution for this interview question. I understood some greedy approach from discussion, but it's hard for me to propose. The only possibility, in my opinion, is that when you saw the question, your brain chose the right angle immediately.
This reflects one embarrassment of summarizing known techniques: there is always a new problem that can't be solved by them.
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.