String FAQ

1. Rotate the string

  1.str1="1234",str2="2341"

  2. Determine whether str2 is the rotation string of str1:

    1.str=str1+str1 ,即"12341234"

    2. Use the kmp algorithm (O(m+n)) to determine whether str contains str2

  3. Any substring of length N in str is a rotated string of str1.

2. String reverse order

  str1="god i like you." 变为str2="you like i god"

  step:

    1. Reverse the string to ".uoy ekil i dog"

    2. Reverse word by word, "you. like i god"

    3. Reverse method:

     Reverse by parity of string length.

      

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325205211&siteId=291194637