Related problems on LeetCode (easy)
9, 14, 20, 28, 58, 66, 73,
125, 168, 171, 186, 189,
205,242, 246, 266, 290, 293,
344, 345, 383, 387, 389,
408, 409, 412, 415, 422, 434, 438, 459
520, 551, 557, 559
Common methods:
- String.substring(start, end)
- Integer.toString()
- Character.isLetterOrDigit()
- Character.toLowerCase()
- Character.isDigit()
- map.containsValue()
- map.containsKey()
- Integer.parseInt(abbr.charAt(i)+””); // When encountering a char to number conversion...
- ArrayList.clear()
- list.toArray(new String[0]);
- toCharArray()
Skill:
- When you need to count, use int[] or array[s.charAt(i) – ‘a’]. If you need uppercase, use uppercase A (this is especially useful).
- When encountering corresponding relationships, use a hashmap to store these relationships, such as Isomorphic Strings.
- Palindrome and similar terms can be stored directly in a hashset. Finally, confirm the size of the hashset (1 and 0 are correct).
- If you encounter something that is inverted from the middle, you can consider inverting it -> processing it -> inverting it again.
- For iteration, use two pointers whenever possible.
- All characters that need to be replaced should first be converted to arrays.
Precautions:
- If you need to change the order, you should usechar`s1 = s.toCharArray();` converts a string into a char array, allowing operations to be performed on the array.
- For strings, use `length()`; for arrays, use `length`; for ArrayLists, use `size()`.
- When using a while loop, the inner while loop must be accompanied by an outermost condition.
Special questions requiring review:
https://blog.jing.do/4642
https://blog.jing.do/4636
https://blog.jing.do/4705
https://blog.jing.do/4878
https://blog.jing.do/4858
This siteOriginal articleAll follow "Attribution-NonCommercial-ShareAlike 4.0 License (CC BY-NC-SA 4.0)Please retain the following annotations when sharing or adapting:
Original author:Jake Tao,source:Summary of String Problem-Solving Methods