MCPcopy
hub / github.com/qiyuangong/leetcode / cmp_alien

Method cmp_alien

java/953_Verifying_an_Alien_Dictionary.java:14–24  ·  view source on GitHub ↗
(String a, String b)

Source from the content-addressed store, hash-verified

12
13 }
14 private int cmp_alien(String a, String b) {
15 int ls = a.length() < b.length() ? a.length(): b.length();
16 int pos = 0;
17 // Compare based on hashmap
18 while (pos < ls) {
19 if (orderMap.get(a.charAt(pos)) != orderMap.get(b.charAt(pos)))
20 return orderMap.get(a.charAt(pos)) - orderMap.get(b.charAt(pos));
21 pos += 1;
22 }
23 return a.length() <= b.length() ? -1: 1;
24 }
25}

Callers 1

isAlienSortedMethod · 0.95

Calls 1

getMethod · 0.45

Tested by

no test coverage detected