String - linear data structure
- String is
immutable
- char array is
mutable
StringBuilder
reduce space complexityPalindrome
problembound check
length -1
Edge case
consideration,detail case problem
- use
Integer.MAX_VALUE / 10
andInteger.MAX_VALUE % 10
to checkoverflow
- string is a linear structure, could use
Dynamic Programming
to solveoptimization problems
Regular expression matching
is aDP
or recursion problems, just try out all possiblilitiesbrute force
solution to visiteeach character
in the string onces.toCharArray()
return a char array char[]- use
26 letters
arrayfreq[]
to reduce space complexity toO(1)