11
11
* @time: 10:32 AM
12
12
* @see: me.ramswaroop.strings.StringPermutations for a simpler version
13
13
*/
14
- public class StringPermutationCount {
14
+ public class StringPermutationsCount {
15
15
16
16
/**
17
17
* Finds the number of permutations of string {@param s1} that exists in string {@param s2}.
@@ -22,20 +22,20 @@ public class StringPermutationCount {
22
22
* @param count
23
23
* @return
24
24
*/
25
- public static int getStringPermutationCount (String prefix , String s1 , String s2 , int count ) {
25
+ public static int getStringPermutationsCount (String prefix , String s1 , String s2 , int count ) {
26
26
if (s1 .isEmpty ()) {
27
27
if (s2 .indexOf (prefix ) != -1 ) count ++;
28
28
}
29
29
30
30
for (int i = 0 ; i < s1 .length (); i ++) {
31
- count = getStringPermutationCount (prefix + s1 .substring (i , i + 1 ), s1 .substring (0 , i ) + s1 .substring (i + 1 ), s2 , count );
31
+ count = getStringPermutationsCount (prefix + s1 .substring (i , i + 1 ), s1 .substring (0 , i ) + s1 .substring (i + 1 ), s2 , count );
32
32
}
33
33
34
34
return count ;
35
35
}
36
36
37
37
public static void main (String a []) {
38
- System .out .println (getStringPermutationCount ("" , "abc" , "abcba" , 0 ));
39
- System .out .println (getStringPermutationCount ("" , "abc" , "abcbacb" , 0 ));
38
+ System .out .println (getStringPermutationsCount ("" , "abc" , "abcba" , 0 ));
39
+ System .out .println (getStringPermutationsCount ("" , "abc" , "abcbacb" , 0 ));
40
40
}
41
41
}
0 commit comments