2
public boolean isAlienSorted(String[] words, String order) {4
int[] alp = new int[26];6
for (int i = 0; i < order.length(); i++) {7
alp[order.charAt(i) - 'a'] = val;11
0; // if second string is shorter than first then this will be used to check if second is a12
// subset of first starting from the beginning14
for (int i = 0; i < words.length - 1; i++) {16
for (int j = 0; j < words[i].length() && j < words[i + 1].length(); j++) {17
if (words[i].charAt(j) == words[i + 1].charAt(j)) {20
if (alp[words[i].charAt(j) - 'a'] > alp[words[i + 1].charAt(j) - 'a']) {22
} else if (alp[words[i].charAt(j) - 'a'] < alp[words[i + 1].charAt(j) - 'a']) {27
if (flag == 0 && words[i].length() > words[i + 1].length()) {28
return false; // if second word is sub string of first word starting from the beginning,