Given a positive number X. Find the largest Jumping Number smaller than or equal to X.
Jumping Number: A number is called Jumping Number if all adjacent digits in it differ by only 1. All single digit numbers are considered as Jumping Numbers. For example 7, 8987 and 4343456 are Jumping numbers but 796 and 89098 are not.
- Time : O(logX)
- Space : O(logX)
c++
1 | class Solution { |