题解 | #牛牛的协作#
牛牛的协作
https://www.nowcoder.com/practice/ae483ed148b34e14bec1451b3317984d
import java.util.*; public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param s string字符串 * @return int整型 */ public int lengthOfLongestContinuousTasks (String s) { // write code here int max=0; int slow=0; HashSet<Character> setMap = new HashSet<>(); for(int i=0;i<s.length();i++){ if(!setMap.add(s.charAt(i))) { max=Math.max(max,setMap.size()); setMap=new HashSet<>(); i=slow; slow++; }; } return Math.max(max,setMap.size()); } }