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
- Getting Started with Cross-Platform Mobile Application using Flutter
- Analyzing Mobile Data Speeds from TRAI with Pandas
- CBSE Class 11 | Mobile Operating Systems - Symbian, Andriod and iOS
- Convert a sentence into its equivalent mobile numeric keypad sequence
- Check if the binary representation of a number has equal number of 0s and 1s in blocks
- Check if a number has same number of set and unset bits
- Program to check whether the given number is Buzz Number or not
- 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
- Check if a number is in given base or not
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