Given are two integers (x and n). The task is to find an array such that it contains the frequency of index numbers occurring in (x^1, x^2, …., x^(n-1), x^(n) ).
Input: x = 15, n = 3 Output: 0 1 2 2 0 3 0 1 0 0 Numbers x^1 to x^n are 15, 225, 3375. So frequency array is 0 1 2 2 0 3 0 1 0 0. Input: x = 1, n = 5 Output: 0 5 0 0 0 0 0 0 0 0 Numbers x^1 to x^n are 1, 1, 1, 1, 1. So frequency of digits is 0 5 0 0 0 0 0 0 0 0.
- Maintain a frequency count array to store the count of digits 0-9.
- Traverse through each digit of x^1 to x^n, for each digit add 1 to corresponding index in frequency count array.
- Print the frequency array
Below is the implementation of above approach:
0 1 2 2 0 3 0 1 0 0
- Frequency of each element of an array of small ranged values
- Minimum integer that can be obtained by swapping adjacent digits of different parity
- Check if the frequency of all the digits in a number is same
- Check if the Xor of the frequency of all digits of a number N is zero or not
- Difference between the summation of numbers whose frequency of all digits are same and different
- Count different numbers possible using all the digits their frequency times
- Maximum array sum that can be obtained after exactly k changes
- Maximum value obtained by performing given operations in an Array
- Minimum sum obtained from groups of four elements from the given array
- Count of alphabets whose ASCII values can be formed with the digits of N
- Find maximum points which can be obtained by deleting elements from array
- Arrange the array such that upon performing given operations an increasing order is obtained
- Construct an array from XOR of all elements of array except element at same index
- Construct an array from GCDs of consecutive elements in given array
- Replace every elements in the array by its frequency in the array
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.