Back to problems

Count Perfect Wake Numbers up to N

Algorithm · Google · Hard

Requirements Call a positive integer a Perfect Wake Number exactly when it satisfies every condition below: Its base-10 digits are all different from one another. The digit 0 does not appear. An internal digit may not be smaller than each of the digit immediately before it and the digit immediately after it. Put differently, no digit may have two strictly greater adjacent digits, so the sequence cannot contain a strict valley. Part 1 (warm-up): write isPerfect(x). Part 2…

Checking your access…