CSDN Topic Challenge Phase 2
Participation Topic: Algorithm Solution
Article directory
Topic link and description
https://leetcode.cn/problems/string-rotation-lcci/
String rotation. Given two strings s1 and s2, write code to check whether s2 is the rotation of s1 (for example, waterbottle is the rotation of erbottlewat).
Example 1:
Input: s1 = "waterbottle", s2 = "erbottlewat"
Output: True
Example 2:
Input: s1 = "aa", s2 = "aba"
Output: False
Prompt:
The string length is in the range [0, 100000].
illustrate:
Can you call the method that checks the substring only once?
Keywords: splicing and matching kmp algorithm
method one:
run screenshot
the code
public boolean isFlipedString(String s1, String s2) {
if(s1.length()!=s2.length()){
return false;
}
s1 += s1;
return s1.contains(s2);
}
Conclusion
It takes 21 days to form a habit. It has been 23 days since the 7th.
Here is a brief review summary:
- The node paths dfs and bfs of the graph on the first day, by the way, review the related concepts of the graph
- Mock question for the second day, rearranging the spaces between words
- Fast and slow pointer on the third day, regrouped numbers
- The fourth day is also an induction question, beautiful queue
- The fifth day, dynamic programming, the longest fixed difference sequence
- On the sixth day, build a binary tree and review the traversal of the tree
- On the seventh day, beating workers, the lowest cost problem for k people
- Day 8, binary search, array eigenvalues
- Day 9, Greedy Algorithm, Maximum Exchange
- Day 11, truth tables, finding patterns, light bulb switches
- Day 12, first contact scan line, area covered
- Thirteenth day, sliding window, hash table, the longest string between the same characters
- Day 15, matrix, hash table, artificial island
- Day 16, pruning, recursion, finding k equal subsets
- The eighteenth day is also a hash table, whether it can be connected into an array
- On the 20th day, three methods, XOR, summation, in-place hash, seeking to disappear double digits
- The twenty-first day, hash table, reordering, character rearrangement
Welcome to communicate in the comment area, check in every day, and rush! ! !