Solution 1 traverse + simulate

  • t-complexity: $O(n)$

  • s-complexity: $O(1)$

Last updated