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
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.
- Print all K digit repeating numbers in a very large number
- How to store a very large number of more than 100 digits in C++
- Print all the non-repeating words from the two given sentences
- Generate a number such that the frequency of each digit is digit times the frequency in given number
- Print Longest substring without repeating characters
- Perform n steps to convert every digit of a number in the format [count][digit]
- Print all possible combinations of the string by replacing '$' with any other digit from the string
- Print all Possible Decodings of a given Digit Sequence
- Sum of all elements repeating 'k' times in an array
- Maximum product from array such that frequency sum of all repeating elements in product is less than or equal to 2 * k
- Count of all unique substrings with non-repeating characters
- Count all distinct pairs of repeating elements from the array for every array element
- Check if a large number is divisible by a number which is a power of 2
- Remainder with 7 for large numbers
- Sum of two large numbers
- Difference of two large numbers
- Multiply Large Numbers represented as Strings
- Compare Version Numbers with large inputs allowed
- Subtraction of two large numbers using 9's compliment
- Subtraction of two large numbers using 10's compliment
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. 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.