@@ -36,14 +36,14 @@ private UniqueSubsequencesCount() {
36
36
* @param str the input string from which subsequences are generated
37
37
* @return the total count of unique subsequences
38
38
*/
39
- public static int countSubsequences (String str ) {
39
+ public static int countSubseq (String str ) {
40
40
41
41
// DP array initialized to store intermediate results
42
42
int [] dp = new int [str .length () + 1 ];
43
43
Arrays .fill (dp , -1 );
44
44
45
45
// Calls the recursive function to compute the result
46
- return recursiveCall (str , 0 , dp );
46
+ return countSubsequences (str , 0 , dp );
47
47
}
48
48
49
49
/**
@@ -59,7 +59,7 @@ public static int countSubsequences(String str) {
59
59
* @return the total number of unique subsequences starting from the
60
60
* current index
61
61
*/
62
- public static int recursiveCall (String st , int idx , int [] dp ) {
62
+ public static int countSubsequences (String st , int idx , int [] dp ) {
63
63
64
64
// Base case: when index exceeds the string length
65
65
if (idx >= st .length ()) {
@@ -88,7 +88,7 @@ public static int recursiveCall(String st, int idx, int[] dp) {
88
88
set .add (st .charAt (j ));
89
89
90
90
// 1 for the current subsequence + recursive call for the rest of the string
91
- res = 1 + recursiveCall (st , j + 1 , dp ) + res ;
91
+ res = 1 + countSubsequences (st , j + 1 , dp ) + res ;
92
92
}
93
93
94
94
// Memoize the result
0 commit comments