public boolean isScrambleRecur(String s1, String s2){
        if(s1.length() != s2.length()) return false;

        char[] arr1 = s1.toCharArray();
        char[] arr2 = s2.toCharArray();
        Arrays.sort(arr1);
        Arrays.sort(arr2);
        String sorted1 = new String(arr1);
        String sorted2 = new String(arr2);

        if(!sorted1.equals(sorted2)) return false;
        if(s1.equals(s2)) return true;

        int len = s1.length();
        int k = 1;
        while(k < len){
            String left1 = s1.substring(0, k);
            String left2 = s1.substring(k);

            String right1 = s2.substring(0, k);
            String right2 = s2.substring(k);

            if((isScramble(left1, right1) && isScramble(left2, right2)))
                return true;

            right1 = s2.substring(len - k);
            right2 = s2.substring(0, len - k);

            if(isScramble(left1, right1) && isScramble(left2, right2))
                return true;
            k++;
        }
        return false;
    }