package leetcode;

/**
 * https://leetcode.com/problems/verifying-an-alien-dictionary/
 */
public class Problem953 {
    public boolean isAlienSorted(String[] words, String order) {
        // TODO
        return false;
    }

    public static void main(String[] args) {
        Problem953 prob = new Problem953();
        System.out.println(prob.isAlienSorted(new String[]{"hello", "leetcode"}, "hlabcdefgijkmnopqrstuvwxyz")); // true
        System.out.println(prob.isAlienSorted(new String[]{"word", "world", "row"}, "worldabcefghijkmnpqstuvxyz")); // false
        System.out.println(prob.isAlienSorted(new String[]{"apple", "app"}, "abcdefghijklmnopqrstuvwxyz")); // false
    }
}

@@ -12,16 +12,42 @@
 tcode;%0A%0A
+import java.util.Arrays;%0A%0A
 /**%0A * h
@@ -213,496 +213,856 @@
     
-// TODO%0A        return false
+String%5B%5D sorted = Arrays.copyOf(words, words.length);%0A        int%5B%5D o = order(order)
 ;%0A    
-%7D%0A%0A
     
-public static void main(String%5B%5D args) %7B%0A        Problem953 prob = new Problem953();%0A        System.out.println(prob.isAlienSorted(new String%5B%5D%7B%22hello%22, %22leetcode%22%7D, %22hlabcdefgijkmnopqrstuvwxyz%22)); // true%0A        System.out.println(prob.isAlienSorted(new String%5B%5D%7B%22
+Arrays.sort(sorted, (a, b) -%3E %7B%0A            int min = Math.min(a.length(), b.length());%0A            for (int i = 0; i %3C min; i++) %7B%0A                int diff = o%5Ba.charAt(i) - 'a'%5D - o%5Bb.charAt(i) - 'a'%5D;%0A                if (diff != 0) %7B%0A                    return diff;%0A                %7D%0A            %7D%0A            if (a.length() %3C b.length()) %7B%0A                return -1;%0A            %7D else if (a.length() %3E b.length()) %7B%0A                return 1;%0A            %7D%0A            return 0;%0A        %7D);%0A        return Arrays.equals(
 word
-%22, %22world%22, %22row%22%7D, %22worldabcefghijkmnpqstuvxyz%22)); // false%0A        System.out.println(prob.isAlienSorted(new String%5B%5D%7B%22apple%22, %22app%22%7D, %22abcdefghijklmnopqrstuvwxyz%22)); // false
+s, sorted);%0A    %7D%0A%0A    private static int%5B%5D order(String s) %7B%0A        int%5B%5D order = new int%5Bs.length()%5D;%0A        for (int i = 0; i %3C s.length(); i++) %7B%0A            order%5Bs.charAt(i) - 'a'%5D = i;%0A        %7D%0A        return order;
 %0A   

Solve problem 953