modify code

master
algorithmzuo 2 years ago
parent 40d65b2dc6
commit 5f6df1a2a6

@ -15,7 +15,7 @@ public class Problem_0411_MinimumUniqueWordAbbreviation {
if ((fix & (1 << i)) != 0) { if ((fix & (1 << i)) != 0) {
ans++; ans++;
if (cnt != 0) { if (cnt != 0) {
ans += (cnt > 9 ? 2 : 1) - cnt; ans += 1;
} }
cnt = 0; cnt = 0;
} else { } else {
@ -23,13 +23,13 @@ public class Problem_0411_MinimumUniqueWordAbbreviation {
} }
} }
if (cnt != 0) { if (cnt != 0) {
ans += (cnt > 9 ? 2 : 1) - cnt; ans += 1;
} }
return ans; return ans;
} }
// 原始的字典,被改了 // 原始的字典,被改了
// target : abc 字典中的词 : bbb -> 101 -> int -> // target : abc 字典中的词 : bbb -> 101 -> int ->
// fix -> int -> 根本不用值,用状态 -> 每一位保留还是不保留的决定 // fix -> int -> 根本不用值,用状态 -> 每一位保留还是不保留的决定
public static boolean canFix(int[] words, int fix) { public static boolean canFix(int[] words, int fix) {
for (int word : words) { for (int word : words) {

Loading…
Cancel
Save