Sort 1201 Discussions, By:
Please Login in order to post a comment
If you sort the array of students, the problem becomes much easier. You just have to check if the value of i[K-1]<=0 to know whether the class should be cancelled or not.
As a general comment, the naming of variables/"things" on HR drives me mad. HackerRank is teaching programmers to use shitty variable names that don't communicate any understanding of the problem. The first thing I do on a challenge is to give things proper names--my mind can't handle "t, N, x, MM, R, and c".
with Python 3
t = int(input().strip())
for _ in range(t):
n,k = map(int,input().strip().split(' '))
a = [int(a_temp) for a_temp in input().strip().split(' ')]
print('YES' if len([i for i in a if i<=0])<k else 'NO')
I am able to pass only first testcase. Any help guys?
26 94 -95 34 67 -97 17 52 1 86
for this test case answer should be NO
but in solution they have shown YES