My issue
t = int(input())
for _ in range(t):
n,k = map(int,input().split())
arr = list(map(int,input().split()))
students_vote = {}
for i in range(n):
if arr[i]==i+1:
continue
elif arr[i] not in students_vote:
students_vote[arr[i]]=1
else:
students_vote[arr[i]]+=1
print(students_vote)
c=0
for key in students_vote:
if students_vote[key]>=k:
c+=1
print(c)
whats wrong in this code …
My code
# cook your dish here
t = int(input())
for _ in range(t):
n,k = map(int,input().split())
arr = list(map(int,input().split()))
students_vote = {}
for i in range(n):
if arr[i]==i+1:
continue
elif arr[i] not in students_vote:
students_vote[arr[i]]=1
else:
students_vote[arr[i]]+=1
print(students_vote)
c=0
for key in students_vote:
if students_vote[key]>=k:
c+=1
print(c)
Problem Link: STUDVOTE Problem - CodeChef