Ctrl K

Twice the Runner-Up

Easy
You are given a list of results scores in which the highest value occurs exactly once. Call the win clear if the best result is at least twice every other result. If the win is clear, return the index of the best result; otherwise return -1.
Example 1
scores=[4, 15, 7, 0] → 1

The best score is 15 and the runner-up has 7. Since 15 ≥ 2 · 7 = 14, the win is clear, so the answer is index 1.

Example 2
scores=[10, 6, 3] → -1

10 < 2 · 6 = 12, so the lead is not big enough.

Example 3
scores=[0, 1] → 1
Constraints
  • 2 ≤ len(scores) ≤ 50
  • 0 ≤ scores[i] ≤ 100
  • The maximum of scores is unique
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsMerge Into the Spare Tail EasyThe Candidate With Most Votes EasyDoes Any Value Repeat EasyMake It to Every Meeting EasyThe Lost Ticket Easy
loading Python…
Input
scores=[4, 15, 7, 0]
Expected
1

Run checks the first 3 tests in your browser. Submit checks all 131 tests on the server, hidden ones included.