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
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.
- 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
- Count different numbers possible using all the digits their frequency times
- Difference between the summation of numbers whose frequency of all digits are same and different
- Maximum array sum that can be obtained after exactly k changes
- Minimum sum obtained from groups of four elements from the given array
- Maximum value obtained by performing given operations in an Array
- 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
- Count of alphabets whose ASCII values can be formed with the digits of N
- Construct an Array of Strings having Longest Common Prefix specified by the given Array
- Construct an array from GCDs of consecutive elements in given array
- Construct an array from XOR of all elements of array except element at same index
- Construct the Array using given bitwise AND, OR and XOR
- Construct the smallest possible Array with given Sum and XOR
- Replace every elements in the array by its frequency in the array
- Construct an array from its pair-product
- Construct sum-array with sum of elements in given range
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.