Skip to content

Commit d0565fe

Browse files
refactor 796
1 parent aba302b commit d0565fe

File tree

1 file changed

+11
-30
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+11
-30
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,17 @@
11
package com.fishercoder.solutions;
22

3-
/**
4-
* 796. Rotate String
5-
6-
We are given two strings, A and B.
7-
8-
A shift on A consists of taking string A and moving the leftmost character to the rightmost position. For example, if A = 'abcde', then it will be 'bcdea' after one shift on A. Return True if and only if A can become B after some number of shifts on A.
9-
10-
Example 1:
11-
Input: A = 'abcde', B = 'cdeab'
12-
Output: true
13-
14-
Example 2:
15-
Input: A = 'abcde', B = 'abced'
16-
Output: false
17-
18-
Note:
19-
20-
A and B will have length at most 100.
21-
*/
223
public class _796 {
23-
public static class Solution1 {
24-
public boolean rotateString(String A, String B) {
25-
if (A.length() != B.length()) {
26-
return false;
27-
}
28-
for (int i = 0; i < A.length(); i++) {
29-
if ((A.substring(i) + A.substring(0, i)).equals(B)) {
30-
return true;
4+
public static class Solution1 {
5+
public boolean rotateString(String A, String B) {
6+
if (A.length() != B.length()) {
7+
return false;
8+
}
9+
for (int i = 0; i < A.length(); i++) {
10+
if ((A.substring(i) + A.substring(0, i)).equals(B)) {
11+
return true;
12+
}
13+
}
14+
return false;
3115
}
32-
}
33-
return false;
3416
}
35-
}
3617
}

0 commit comments

Comments
 (0)