[
sort
array
]
BinarySearch 0020 Largest Number By Two Times
Problem statement
https://binarysearch.com/problems/Largest-Number-By-Two-Times/
Solution
Similar to leetcode 747. Largest Number At Least Twice of Others.
Complexity
Here time complexity is O(n log n)
, it is possible to solve it in O(n)
as well. Space complexity is O(n)
.
Code
class Solution:
def solve(self, nums):
nums = sorted(nums)
return nums[-1] > 2 * nums[-2]