Perfect Number
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
A **perfect number** is a positive integer equal to the sum of its positive divisors excluding itself. For example, 28 = 1 + 2 + 4 + 7 + 14.
Given an integer num, return true if it is a perfect number and false otherwise. Note that 1 is not perfect (its only proper divisor sum is 0).
Aim for O(√num) time by pairing divisors.
Examples
Constraints
- 1 <= num <= 10^8
- Proper divisors exclude `num` itself.
- The input is a positive integer.
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.