Given a very large number, print all the 3 digit repeating numbers with their frequency. If a 3 digit number appears more then once, print the number and its frequency.
Input: 123412345123456 Output: 123 - 3 times 234 - 3 times 345 - 2 times Input: 43243243 Output: 432 - 2 times 324 - 2 times 243 - 2 times
Approach: Since the number is very large, it is stored in a string. Initially, the first three digit number will be the first three characters from the left. Iterate in the string from the 3rd index from the left in the string and do %100 to remove the first character and append the ith index number at the end to get the new number. Increase the frequency of the number in the hash map. In the end, when all the 3 digit numbers are generated, print all the numbers which have a frequency of more than 1.
Below is the implementation of the above idea:
123 - 3 times 234 - 3 times 345 - 2 times
- Print Longest substring without repeating characters
- Perform n steps to convert every digit of a number in the format [count][digit]
- Sum of two large numbers
- Difference of two large numbers
- Remainder with 7 for large numbers
- Multiply Large Numbers represented as Strings
- Generate a number such that the frequency of each digit is digit times the frequency in given number
- Compare Version Numbers with large inputs allowed
- Factorial of a large number
- Maximum and minimum sums from two numbers with digit replacements
- Check if a large number is divisible by 11 or not
- Check if a large number is divisible by 4 or not
- To check divisibility of any large number by 999
- To check whether a large number is divisible by 7
- Divide large number represented as string
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 : Nishant Tanwar