package leetcode;

/**
 * https://leetcode.com/problems/longest-nice-substring/
 */
public class Problem1763 {
    public String longestNiceSubstring(String s) {
        StringBuilder answer = new StringBuilder();
        // TODO
        return answer.toString();
    }

    public static void main(String[] args) {
        Problem1763 prob = new Problem1763();
        System.out.println(prob.longestNiceSubstring("YazaAay")); // "aAa"
        System.out.println(prob.longestNiceSubstring("Bb")); // "Bb"
        System.out.println(prob.longestNiceSubstring("c")); // ""
        System.out.println(prob.longestNiceSubstring("dDzeE")); // "dD"
        System.out.println(prob.longestNiceSubstring("aBbA")); // "aBbA"
        System.out.println(prob.longestNiceSubstring("aBbAa")); // "aBbAa"
    }
}

@@ -169,23 +169,16 @@
   String
-Builder
  answer 
@@ -183,77 +183,975 @@
 r = 
-new StringBuilder();%0A        // TODO%0A        return answer.toString()
+%22%22;%0A        for (int i = 0; i %3C s.length(); i++) %7B%0A            for (int j = i + 1; j %3C s.length(); j++) %7B%0A                String sub = s.substring(i, j + 1);%0A                if (isNice(sub)) %7B%0A                    if (sub.length() %3E answer.length()) %7B%0A                        answer = sub;%0A                    %7D%0A                %7D%0A            %7D%0A        %7D%0A        return answer;%0A    %7D%0A%0A    private static boolean isNice(String s) %7B%0A        boolean%5B%5D lower = new boolean%5B26%5D;%0A        boolean%5B%5D upper = new boolean%5B26%5D;%0A        for (char c : s.toCharArray()) %7B%0A            if (Character.isUpperCase(c)) %7B%0A                upper%5Bc - 'A'%5D = true;%0A            %7D else %7B%0A                lower%5Bc - 'a'%5D = true;%0A            %7D%0A        %7D%0A        for (char c : s.toCharArray()) %7B%0A            if ((Character.isUpperCase(c) && !lower%5Bc - 'A'%5D) %7C%7C%0A                (Character.isLowerCase(c) && !upper%5Bc - 'a'%5D)) %7B%0A                return false;%0A            %7D%0A        %7D%0A        return true
 ;%0A  

Update problem 1763