Practice Happy Students
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Choose a group of students. Student i is happy when selected and the group size is strictly greater than nums[i], or when not selected and the group size is strictly smaller than nums[i]. Return the number of groups that make every student happy, including the empty group when it satisfies these rules.
Source: Happy Students on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
nums = [1,1]
Output
2
# Example 2
Input
nums = [6,0,3,3,6,7,2,7]
Output
3
Constraints
1 <= nums.length <= 10^5
0 <= nums[i] < nums.length
Related LeetCode Problems
Practice more problems similar to Happy Students.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.