Given a mobile number and some conditions for a fancy number, find if the given number is fancy. A 10 digit mobile number is called fancy if it satisfies any of the following three conditions.
- A single number occurs three consecutive times. Like 777.
- Three consecutive digits are either in increasing or decreasing fashion. Like 456 or 987.
- A single digit occurs four or more times in the number. Like 9859009976 – here the digit 9 occurs 4 times.
Input : 9859009976
Output : Yes
The given mobile number satisfies condition
three given above.
Input : 7609438921
Output : No
None of the given three conditions satisfy.
Idea is to convert number into string using to_string so that it becomes easy to traverse. For condition three to count the frequency of every number a basic concept of string hashing is used.
Source :Oracle Interview Set
Below is the solution of above problem.
- Mobile Numeric Keypad Problem
- Count of buttons pressed in a keypad mobile
- Analyzing Mobile Data Speeds from TRAI with Pandas
- Getting Started with Cross-Platform Mobile Application using Flutter
- Convert a sentence into its equivalent mobile numeric keypad sequence
- CBSE Class 11 | Mobile Operating Systems - Symbian, Andriod and iOS
- Check if the binary representation of a number has equal number of 0s and 1s in blocks
- Program to check whether the given number is Buzz Number or not
- Check if a number has same number of set and unset bits
- Check if a number is a Krishnamurthy Number or not
- Check Whether a number is Duck Number or not
- Check if a number is a Mystery Number
- Check if a number is a Trojan Number
- Check whether a given number is even or odd
- Check if a number is Palindrome
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 Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : ash264