Skip to content

Commit 33f06a8

Browse files
authored
Update UniqueSubsequencesCount.java
1 parent d99c476 commit 33f06a8

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

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

+7-3
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,17 @@ private UniqueSubsequencesCount() {
1414
throw new UnsupportedOperationException("Utility class");
1515
}
1616

17+
private static int[] dp;
18+
1719
public static int subseqCount(String str) {
18-
int[] dp = new int[str.length() + 1];
20+
21+
dp = new int[str.length() + 1];
22+
1923
for (int i : dp) {
2024
Arrays.fill(dp, -1);
2125
}
22-
int ans = recursiveCall(str, 0, dp);
23-
return ans;
26+
27+
return recursiveCall(str, 0, dp);
2428
}
2529

2630
public static int recursiveCall(String st, int idx, int[] dp) {

0 commit comments

Comments
 (0)