The R1 coding interviewer was very encouraging the whole way through (thanks to him), but I was too nervous and didn't perform very well.
First, the initial problem. A "perfect wake number" is defined as:
- no 0
- no repeated digits
- for every digit, its two adjacent digits are not higher than that digit
Write a function isPerfectWakeNumber(n: int). For example, 123 should return false.
I used brute force overall, with time complexity n*m.
Then the follow-up: how many perfect wake numbers are there in the range [1, 9999]? The interviewer was also very patient and made it easier for me, asking how I would think about it if I only considered the first two digits. I figured it could be done with subset backtracking, but in the end I didn't finish writing the whole method.
The BQ round got rescheduled, but overall I don't think I'm likely to pass.
Discussion
Loading comments…