@@ -0,0 +1,1014 @@
+// https://leetcode.com/problems/longest-substring-with-at-most-two-distinct-characters/%0A// #159%0A%0Aclass Solution %7B%0A    public int lengthOfLongestSubstringTwoDistinct(String s) %7B%0A        Character current1 = '_';%0A        Character current2 = '_';%0A        int max = 0;%0A        for (int j = 0; j %3C s.length(); j++) %7B%0A            int counter = 0;%0A            for (int i = j; i %3C s.length(); i++) %7B%0A                if (current1.equals('_'))%7B%0A                    current1 = s.charAt(i);%0A                %7D%0A                else if ((current2 == null) && (s.charAt(i)!=current1)) %7B%0A                    current2 = s.charAt(i);%0A                %7D%0A                else if ((s.charAt(i)!=current1)&&(s.charAt(i)!=current2)) %7B%0A                    break;%0A                %7D%0A                else %7B%0A                    counter++;%0A                %7D%0A            %7D%0A            current1 = '_';%0A            current2 = '_';%0A            if (counter %3E max) %7B%0A                max = counter;%0A            %7D%0A        %7D%0A        return max;%0A    %7D%0A%7D

longestsubstring naive