Part 1 is basically a linear scan and I got through it fine.
First, clarify the definition and edge cases, then implement a helper function to check if a number is a Perfect Wake Number by extracting digits and verifying distinctness and the interior digit condition. For counting, consider that the maximum possible number is 987654321 (all digits distinct), so for n beyond that, the count is fixed; for smaller n, you can either iterate with the check or use digit DP to count efficiently.
Pro tip: Mention that the total count of Perfect Wake Numbers is finite (at most 9! = 362880) and can be precomputed, so for large n you can just return the precomputed count. This shows you think about scalability and optimization.
Restate the definition of a Perfect Wake Number and confirm edge cases: single-digit numbers (trivially qualify), numbers with zero (disqualified), and the maximum possible number (987654321).
Write a function that takes an integer, extracts its digits, checks that all digits are non-zero and distinct, and verifies that no interior digit is strictly smaller than both neighbors.
For small n, iterate from 1 to n and apply the check. For large n, use digit DP or precompute all valid numbers (since the maximum is 987654321) and count those ≤ n.
If n ≥ 987654321, return the total count of Perfect Wake Numbers. Otherwise, use the chosen method to count efficiently, possibly with memoization or precomputed list.
Test with small ranges, edge cases (n=1, n=9, n=10, n=100), and compare with brute force for small n to ensure correctness.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.