https://leetcode.com/problems/odd-string-difference/
Beats 19.92%of users with Java
class Solution {
public String oddString(String[] words) {
HashMap<String, String> res = new HashMap();
for (String s : words) {
int[] diff2 = new int[words[0].length() - 1];
extracted(s.toCharArray(), diff2);
res.put(Arrays.toString(diff2), res.getOrDefault(Arrays.toString(diff2),"")+ s);
}
return res.values().stream()
.min(Comparator.comparingInt(String::length))
.get();
}
private void extracted(char[] charArray, int[] diff) {
for (int i = 0; i < charArray.length - 1; i++) {
diff[i] = charArray[i + 1] - charArray[i];
}
}
}