Skip to content

Commit ad8f848

Browse files
refactor 340
1 parent c174013 commit ad8f848

File tree

1 file changed

+2
-4
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+2
-4
lines changed

src/main/java/com/fishercoder/solutions/_340.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@ public int lengthOfLongestSubstringKDistinct(String s, int k) {
2929
num++;
3030
}
3131
if (num > k) {
32-
while (--count[s.charAt(left++)] > 0) {
33-
}
34-
;
32+
while (--count[s.charAt(left++)] > 0);
3533
num--;
3634
}
3735
result = Math.max(result, right - left + 1);
@@ -41,7 +39,7 @@ public int lengthOfLongestSubstringKDistinct(String s, int k) {
4139
}
4240

4341
public static class Solution2 {
44-
/**This is a more generic solution for any characters.*/
42+
/**This is a more generic solution for any characters, not limited to ASCII characters.*/
4543
public int lengthOfLongestSubstringKDistinct(String s, int k) {
4644
Map<Character, Integer> map = new HashMap<>();
4745
int longest = 0;

0 commit comments

Comments
 (0)