File tree Expand file tree Collapse file tree 1 file changed +24
-20
lines changed
src/main/java/com/fishercoder/solutions Expand file tree Collapse file tree 1 file changed +24
-20
lines changed Original file line number Diff line number Diff line change 22
22
*/
23
23
public class _466 {
24
24
25
- /**credit: https://discuss.leetcode.com/topic/70707/ugly-java-brute-force-solution-but-accepted-1088ms*/
26
- public int getMaxRepetitions (String s1 , int n1 , String s2 , int n2 ) {
27
- char [] s1chars = s1 .toCharArray ();
28
- char [] s2chars = s2 .toCharArray ();
29
- int i = 0 ;
30
- int j = 0 ;
31
- int count1 = 0 ;
32
- int count2 = 0 ;
33
- while (count1 < n1 ) {
34
- if (s1chars [i ] == s2chars [j ]) {
35
- j ++;
36
- if (j == s2 .length ()) {
37
- j = 0 ;
38
- count2 ++;
25
+ public static class Solution1 {
26
+ /**
27
+ * credit: https://discuss.leetcode.com/topic/70707/ugly-java-brute-force-solution-but-accepted-1088ms
28
+ */
29
+ public int getMaxRepetitions (String s1 , int n1 , String s2 , int n2 ) {
30
+ char [] s1chars = s1 .toCharArray ();
31
+ char [] s2chars = s2 .toCharArray ();
32
+ int i = 0 ;
33
+ int j = 0 ;
34
+ int count1 = 0 ;
35
+ int count2 = 0 ;
36
+ while (count1 < n1 ) {
37
+ if (s1chars [i ] == s2chars [j ]) {
38
+ j ++;
39
+ if (j == s2 .length ()) {
40
+ j = 0 ;
41
+ count2 ++;
42
+ }
43
+ }
44
+ i ++;
45
+ if (i == s1 .length ()) {
46
+ i = 0 ;
47
+ count1 ++;
39
48
}
40
49
}
41
- i ++;
42
- if (i == s1 .length ()) {
43
- i = 0 ;
44
- count1 ++;
45
- }
50
+ return count2 / n2 ;
46
51
}
47
- return count2 / n2 ;
48
52
}
49
53
50
54
}
You can’t perform that action at this time.
0 commit comments