Skip to content

Commit d7dcfe4

Browse files
refactor 340
1 parent e929509 commit d7dcfe4

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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy