Frequency of Limited Range Array Elements | DSA | Programming Tutorials | GeeksforGeeks
Вставка
- Опубліковано 20 жов 2020
- Our courses :
practice.geeksforgeeks.org/co...
This video is contributed by Rahul Singla
Please Like, Comment and Share the Video among your friends.
Install our Android App:
play.google.com/store/apps/de...
If you wish, translate into the local language and help us reach millions of other geeks:
ua-cam.com/users/timedtext_cs_p...
Follow us on Facebook:
/ gfgvideos
And Twitter:
/ gfgvideos
Also, Subscribe if you haven't already! :)
GREAT EXPLAINATON!!
Everyone is just repeating the written code but you explained that why we do all the steps.
I am commenting so that people should know that u have explained very well(every bit). And if someone doesn't get it then watch it again
The best explaination I have seen so far ,thanks a lot for the last two efficient approaches , but in the last but one approach I got confused when you said e as arr[i]-e ,but it's actually arr[i]-1
Extremely well explained. Thank you so much Sir. Keep it up!!!
Awesome thinking
In the starting i just got the frequency array concept
The new one is really gud
Last approach is the best, 2nd last does count to O(N) in Big-Oh, but we iterate more than N times so its not as good as the last one.
best explain sir and very very thanks from bottom of my heart
Thanks for the explanation!
Hi
I have an array of positive integer {12,32,34,63,16,65,60}. My task is to count the occurence of each digit and return array with digits having max counts .
Output
arr2={1,2,3,6}.
initial array is 2 3 2 3 5 then answer should be 0 2 2 0 1, but in 18:49 you say that its 0 2 1 0 1
The last method has some edge case issues
23:01 best one 😊
nice 👏👏
Thanks for the visit
Last approach is not good, it will not work in many cases
Yes I am getting runtime error for last approach on some test case cases. But I don't know which one.
I think it is because of int overflow
you need to add few checks before you can paste the code. .. see some articles for greater insight
@@piyush2947 is it fixed now ,
same problem here as well
tell me the solution if you got it.
TBH I spend more then hour to solve this problem and if you're beginner too then jump into second explanation that will be 23:05 and understand from there don't waste your time in first explanation because that is worst .
JAVA SOLUTION IS HERE:
class Solution{
//Function to count the frequency of all elements from 1 to N in the array.
public static void frequencyCount(int arr[], int N, int P)
{
// code here
int i=0;
while(iN){
arr[i]=0;
}
if(arr[i]
Can anyone tell why Signal Abort 3 error coming in my code
void frequencyCount(vector& arr,int N, int P)
{
//SUBTRACT 1 FROME EACH ELEMENT SO THAT IT BECOMES INT THE RANGE 0 TO P-1
for(int i=0;i
i am also getting the same error , can't get where is error. Can anyone help ?
(N) space not o(1) at
he is modifying the same array so O(1) space
The last algorithmic approach is giving runtime error;
TRY THIS :
class Solution{
//Function to count the frequency of all elements from 1 to N in the array.
public static void frequencyCount(int arr[], int N, int P)
{
int counti=0;
for(int i=0;iN)
{
arr[i]=0;
counti++;
}
else
arr[i]--;
}
for(int i=0;i
sorry but not pleased with the explanation(especially the last one)