Skip to content

Commit 002d55f

Browse files
authored
Update UniqueSubsequencesCount.java
1 parent 697c108 commit 002d55f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/main/java/com/thealgorithms/dynamicprogramming/UniqueSubsequencesCount.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ private UniqueSubsequencesCount() {
3636
* @param str the input string from which subsequences are generated
3737
* @return the total count of unique subsequences
3838
*/
39-
public static int countSubsequences(String str) {
39+
public static int countSubseq(String str) {
4040

4141
// DP array initialized to store intermediate results
4242
int[] dp = new int[str.length() + 1];
4343
Arrays.fill(dp, -1);
4444

4545
// Calls the recursive function to compute the result
46-
return recursiveCall(str, 0, dp);
46+
return countSubsequences(str, 0, dp);
4747
}
4848

4949
/**
@@ -59,7 +59,7 @@ public static int countSubsequences(String str) {
5959
* @return the total number of unique subsequences starting from the
6060
* current index
6161
*/
62-
public static int recursiveCall(String st, int idx, int[] dp) {
62+
public static int countSubsequences(String st, int idx, int[] dp) {
6363

6464
// Base case: when index exceeds the string length
6565
if (idx >= st.length()) {
@@ -88,7 +88,7 @@ public static int recursiveCall(String st, int idx, int[] dp) {
8888
set.add(st.charAt(j));
8989

9090
// 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;
9292
}
9393

9494
// Memoize the result

0 commit comments

Comments
 (0)