xxl-job-rest
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
package com.wyl.file.sequence;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
class Solution {
|
||||
public static int lengthOfLongestSubstring(String s) {
|
||||
if (s.length() < 0) {
|
||||
return 0;
|
||||
}
|
||||
Map<Character, Integer> map = new HashMap<>();
|
||||
int start = 0;
|
||||
int max = 0;
|
||||
for (int i = 0; i < s.length(); i++) {
|
||||
int c = s.charAt(i);
|
||||
Integer integer = map.get(c);
|
||||
if (Objects.isNull(integer)) {
|
||||
|
||||
} else {
|
||||
start = Math.max(start, integer + 1);
|
||||
}
|
||||
max = Math.max(max, i - start + 1);
|
||||
// map.put(c, i);
|
||||
}
|
||||
return max;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
int i = lengthOfLongestSubstring("tmmzuxt");
|
||||
System.out.println(i);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user