```
class Solution {
public:
int dominantIndex(vector<int>& nums) {
if (nums.size() < 2) return -1;
int first = 0, second = -1;
for (int i = 1; i < nums.size(); i++) {
if (nums[i] > nums[first]) {
second = first;
first = i;
}
else if (second == -1 || nums[i] > nums[second]) second = i;
}
return nums[first] >= nums[second] * 2 ? first : -1;
}
};
```