HELP IN MODEFREQ

https://www.codechef.com/viewsolution/37287056
solution link

The below solution is accepted and it is easy to understand .
https://www.codechef.com/viewsolution/37279799

ok thanks for this
but can you tell me the problem in my solution

1
5
1 1 1 1 1
Try this

mine giving 5

its right, wait i’ll generate random test and we’ll figure it out

7
7 1 2 1 2 1 2 1
10 1 10 9 9 10 7 7 3 3 31
1 5
6 2 2 2 2 2 2
6 1 1 2 2 3 3
9 1 2 3 4 5 6 7 8 9
12 10 10 12 12 1 1 1 1 20 20 19 18

output

3
2
1
6
2
1
2

its fine here too

but for the first round output should be 1

7 => 1
1=> 4
2=> 3

1
5 1 1 1 1 2

try this

1 Like

7 is n, bruh

I told you because this method is used frequently and may be in some different question, chances are high that you may get tle. You can’t be lucky every time :sweat_smile:

1 2 1 2 try this

Can someone help me with my code as well. Where have I gone wrong? My guess is maybe in the for loop but I can’t figure it out.
https://www.codechef.com/viewsolution/37290671

bruh i think u missed braces in if else

what does counter do

Counter counts the occurrence (frequency) of each elements in the list and returns a dictionary of {elems:frequencies}

instead of val = list(map(int, numval.split())), u gave val = list(map(int, input().split()))

Also correct ur code
1
12
10 10 12 12 1 1 1 1 20 20 19 18
o/p: 2
ur o/p: 1