From c5b9e2d8d9f79b6a22d63131df11dd2d7cc56563 Mon Sep 17 00:00:00 2001 From: algorithmzuo Date: Tue, 25 Oct 2022 20:28:15 +0800 Subject: [PATCH] modify code --- .../class17/Code05_DistinctSubseqValue.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/大厂刷题班/class17/Code05_DistinctSubseqValue.java b/大厂刷题班/class17/Code05_DistinctSubseqValue.java index 17f00d5..833f11b 100644 --- a/大厂刷题班/class17/Code05_DistinctSubseqValue.java +++ b/大厂刷题班/class17/Code05_DistinctSubseqValue.java @@ -9,16 +9,17 @@ public class Code05_DistinctSubseqValue { if (s == null || s.length() == 0) { return 0; } - int m = 1000000007; + long m = 1000000007; char[] str = s.toCharArray(); - int[] count = new int[26]; - int all = 1; // 算空集 + long[] count = new long[26]; + long all = 1; // 算空集 for (char x : str) { - int add = (all - count[x - 'a'] + m) % m; + long add = (all - count[x - 'a'] + m) % m; all = (all + add) % m; count[x - 'a'] = (count[x - 'a'] + add) % m; } - return all - 1; + all = (all - 1 + m) % m; + return (int) all; } public static int zuo(String s) {