99. Recover Binary Search Tree

  • travese in order. The result should be sorted ascending. The misplaced larger element will be close to head, while the smaller one will be close to end. For example, 1 2 3 is the in order. But the wrong seq is like 3 2 1. Apparently, 3 > 2 so 3 is the first node. 2 > 1, so 1 is the second one.

  • iterative solution using morris traverse

257. Binary Tree Paths

  • string is immutable.