Geeksforgeeks

Error

×

Leaderboard

Showing:

Handle | Score |
---|---|

@Ibrahim Nash | 6560 |

@blackshadows | 6400 |

@mb1973 | 5777 |

@Quandray | 5275 |

@akhayrutdinov | 5111 |

@saiujwal13083 | 5074 |

@kirtidee18 | 4398 |

@sanjay05 | 3762 |

@mantu_singh | 3654 |

@gfgaccount | 3601 |

@marius_valentin_dragoi | 3525 |

Complete Leaderboard | |

Handle | Score |

@anish5256 | 991 |

@vimleshpratapsingh321 | 980 |

@skj7 | 899 |

@akhileshkumar562002 | 862 |

@kanewilliamson123 | 854 |

@pradeeppatidar1999 | 852 |

@pd420786 | 813 |

@infilooop | 800 |

@bunnybug320 | 796 |

@smitabose7826 | 784 |

@wallflowe101 | 770 |

Complete Leaderboard |

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.

**Example 1:**

Input:X =10Output:10Explanation:10 is the largest Jumping Number possible for X = 10.

**Example 2:**

Input:X =50Output:45Explanation:45 is the largest Jumping Number possible for X = 50.

**Your Task:**

You don't need to read input or print anything. Your task is to complete the function **jumpingNums()** which takes an Integer X as input and returns the largest Jumping Number less than or equal to X.

**Expected Time Complexity:** O(k), where k is no of jumping numbers

**Expected Auxiliary Space:** O(k), where k is no of jumping numbers

**Constraints:**

1 <= X <= 10^{9}

Login to report an issue on this page.

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

YesLoading...

Jumping Numbers

...