You are given a 0-indexed array nums. The largest element is dominant if it is at least twice as large as every other element. Return the index of the dominant element, or -1 if none exists.
Assume the maximum element appears only once.
Input: An integer array nums of length n.
Output: Integer — index of the dominant element, or -1.
Input: [3,6,1,0]
Output: 1
Explanation: max=6 at index 1. 6>=2*3, 6>=2*1, 6>=2*0. Dominant. Return 1.Input: [1,2,3,4]
Output: -1
Explanation: max=4 at index 3. 4<2*3=6. Not dominant. Return -1.Input: [1]
Output: 0
Explanation: Single element — trivially dominant. Return 0.2<=nums.length<=500<=nums[i]<=100nums has a unique maximum element.