Skip to main content
LeetCode 747, Easy. Topics: Array, Sorting. View on LeetCode. Generate this problem as a practice environment: tested reference solution, 30 parametrized pytest cases, and a playground notebook:

Problem

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.

Examples

Constraints

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

Solution

Reference implementation from solution.py on GitHub, full suite in test_solution.py:

Complexity

Tags

Last modified on September 7, 2026