Backtrace idea is straightforward. But there are always smarter solutions - like this:
https://leetcode.com/discuss/87314/non-recursive-time-space-solution-with-detail-explanations
Very neat idea and explanation!