StringBuilder (my solution)
1 | class Solution { |
Remarks:
- TC: $O(2^n)$
- Don’t forget to
pos++
at the end of the while loop - In the
while
statement, first checkpos + 1 < n
then checks.charAt(pos + 1)
.
Java handles logic expression LEFT to RIGHT.
1 | class Solution { |
Remarks:
pos++
at the end of the while loopwhile
statement, first check pos + 1 < n
then check s.charAt(pos + 1)
.