136. Single Number
class Solution {
int singleNumber(List nums) {
int single = 0;
Map myMap = {};
for (int i in nums) {
if (myMap.containsKey(i)) {
myMap[i] = (myMap[i] ?? 0) + 1;
} else {
myMap[i] = 1;
}
}
/// loop below can be eliminated using map's built-in function
for (int i = 0; i < myMap.keys.length; i++) {
if (myMap.values.toList()[i] == 1) {
single = myMap.keys.toList()[i];
break;
}
}
return single;
}
}