I recently worked through the classic Word Break problem in an interview. My approach was solid from the start — recursion with memoization, a breakable helper that tests every prefix and recurses on the rest. The logic was right. What slowed me down was everything around the logic.

Here's the solution I landed on:

class Solution {

public:

bool wordBreak(string s, vector<string>& wordDict) {