(String a, String b)
| 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 | } |