This is just a short summary of what I have learned from the previous problems.
- If you are dealing with Java Strings, converting it to character array might be helpful.
- Ask about the type of characters in the string. Are they ASCII characters?
- Sometimes you will count the frequency of the characters in the string, so ask the second question is important. If they are all ASCII characters, you can just use an array of size 256.
- If you are not allowed to use additional data structures doing string manipulation, think about bit manipulation. The bit format provides you more stuff to work on. You may also want to consider using two index variables to keep track of the character’s position.
- Two ways to exam characters in a string: from the current position and look into the latter parts of the string; or from the current position and look back into the previous parts of the string (which you can keep track of, e.g., character frequency).
- If you are dealing with expanding, consider starting from the end of the string. Otherwise, start from the beginning of the string.
- If the question gives you something (for example, a known function) and you can’t relate it to the question directly, try apply the function simply on the data that are given. See how far the result of that is from the expectation.