Skip to content

Practice Largest Number At Least Twice of Others

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Easy#747
LeetCode Problem

Largest Number At Least Twice of Others

Problem Statement

You are given an integer array nums where the largest integer is unique. Determine whether the largest element in the array is at least twice as much as every other number in the array. If it is, return the index of the largest element, or return -1 otherwise.

Source: Largest Number At Least Twice of Others on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
nums = [3,6,1,0]
Output
1

# Example 2

Input
nums = [1,2,3,4]
Output
-1

Constraints

2 <= nums.length <= 50
0 <= nums[i] <= 100
The largest element in nums is unique.

Related LeetCode Problems

Practice more problems similar to Largest Number At Least Twice of Others.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.