LeetCode – Scramble String (Java)
Given two strings s1 and s2 of the same length, determine if s2 is a scrambled string of s1. Java Solution public boolean isScramble(String s1, String s2) { if(s1.length()!=s2.length()) return false; if(s1.length()==0 || s1.equals(s2)) return true; char[] arr1 = s1.toCharArray(); char[] arr2 = s2.toCharArray(); Arrays.sort(arr1); Arrays.sort(arr2); if(!new String(arr1).equals(new String(arr2))){ return false; } … Read more