Logo
IconChallenge
Icon
IconProblem
IconSolutions
IconSubmissions

Largest Number At Least Twice of Others

XPChallenge Points: 10
levelLevel: Easy

You are given an integer array nums that contains a single unique maximum value.

Your task is to verify whether this maximum value is at least double every other number in the array.
If this condition holds true, return the index of that maximum value.
Otherwise, return -1.

The comparison must check all other values, ensuring the maximum element is at least twice as large as each one individually.

Example 1:

Input: nums = [10, 2, 5, 1]

Output: 0

Explanation:

Maximum = 10 Other values = 2, 5, 1 10 ≥ 2× each of them → condition satisfied. Index of 10 is 0.

Example 2:

Input: nums = [4, 8, 15, 3]

Output: -1

Explanation:

Maximum = 15 Check: 15 < 2×8 → fails So return -1.

to Continue
like
dislike

Accepted:

Submission:

IconReport an issue
Icon
IconCode
IconYou need toto run or submitYou need toto run or submit
IconTest Case
IconTest Result