Keep Multiplying Found Values by Two
给一个数组和一个数字n, 求一直做n乘2, 直到不在数组里找到n.
class Solution {
public int findFinalValue(int[] nums, int original) {
Set<Integer> set = new HashSet<>();
for(int n : nums)
set.add(n);
while(set.contains(original)){
original *= 2;
}
return original;
}
}