bugfree Icon
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course

Leetcode Problem 747. Largest Number At Least Twice of Others

747. Largest Number At Least Twice of Others

Leetcode Solutions

Find Largest and Check if Twice as Large as Others

  1. Initialize two variables to store the maximum value (max_value) and its index (max_index).
  2. Iterate through the array to find the maximum value and its index.
  3. Iterate through the array again to check if the maximum value is at least twice as large as every other number.
  4. If the condition is met for all numbers, return max_index.
  5. If any number does not meet the condition, return -1.
UML Thumbnail

Single Pass with Tracking Largest and Second Largest

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...