FunctionRacerProblemsRace

Largest At Least Twice Others

BeginnerArraysPython, JavaScript, TypeScript, Java, C++

All values in nums are different. If the largest value is at least twice every other value, return its index. Otherwise return -1.

Example 1

nums [3,6,1,0]
returns 1

6 is at least twice 3, 1 and 0. Index 1.

Example 2

nums [1,2,3,4]
returns -1

4 is less than twice 3.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Arrays problems