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.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Check if the given number is Ore number or not
- Check if a number is an Achilles number or not
- Check if a number is Primorial Prime or not
- Program to check if N is a Tridecagonal Number or not
- Check whether Array represents a Fibonacci Series or not
- Check if a number is Flavius Number
- Find if the given number is present in the infinite sequence or not
- Check if a given number is Pronic
- Check if a number is magic (Recursive sum of digits is 1)
- Program to check if N is a Pentagonal Number
- Check if a given number is Pronic | Efficient Approach
- Program to check if N is a Star Number
- Program to check if N is a Chiliagon Number
- Finding number of digits in n'th Fibonacci number
- Super Ugly Number (Number whose prime factors are in given set)
- Number of digits in the nth number made of given four digits
- Find the sequence number of a triangular number
- Program for nth Catalan Number
- N'th Smart Number
- K'th Boom Number