2358. Maximum Number of Groups Entering a Competition
Read the full problem statement on LeetCode.
Difficulty: medium Acceptance: 68% Topics: Array, Math, Binary Search, Greedy
View full problem on LeetCode Reading material
Reference solution (spoiler · python)
# Time: O(1)
# Space: O(1)
# math
class Solution(object):
def maximumGroups(self, grades):
"""
:type grades: List[int]
:rtype: int
"""
# (1+x)*x/2 <= len(grades)
# => x <= ((1+8*len(grades))**0.5-1)/2.0
return int(((1+8*len(grades))**0.5-1)/2.0)
Solution from kamyu104/LeetCode-Solutions · MIT
Similar questions