Write a program to check if a given integer is jumbled or not. A number is said to be Jumbled if for every digit, its neighbours digit differs by max 1.
Input : 6765 Output : True All neighbour digits differ by atmost 1. Input : 1223 Output : True Input : 1235 Output : False
To find if a number is jumbled, we just need to check if a digit has a neighbour
with difference greater than 1. If such digit is found, the number is non-jumbled.
Below is the implementation of above idea :
Related Article :
This article is contributed by Rohit Thapliyal. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
- Check whether all the rotations of a given number is greater than or equal to the given number or not
- Check if a number is divisible by all prime divisors of another number
- Program to check whether a number is Proth number or not
- Check if a number with even number of digits is palindrome or not
- Check if given number is Emirp Number or not
- Check whether a number is Non-hypotenuse number
- Check if a number is an Unusual Number or not
- Check if a number is an Achilles number or not
- Check if a number is a Mystery Number
- Check if a number is a Trojan Number
- Check if a given number is factorial of any number
- Check if a number is a power of another number
- Check if a number is Flavius Number
- How to check if a given number is Fibonacci number?
- Check if a number is a Krishnamurthy Number or not