# Angry Professor

# Angry Professor

amonjerro + 16 comments 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.

TheDapperGinger + 9 comments That's really clever. I wonder how the time complexities stack up for adding everything to the arrays and then sorting them vs just adding everything and iterating over them. I'm trying to learn how to analyze time complexities so here's my stab at it:

Creating the array would be O(n) and then running through it would be O(n) as well so O(2n) total which reduces to O(n)

Using radix sort you'd have O(n) for creating the array + O(nk) for radix sort it'd be O(2nk) or O(nk)

So that would mean that simply iterating would be slightly faster?

Am I right about that or do is my understanding of time complexities still off kilter?

Side note: hackerrank needs comment formatting.

Edited to fix time complexity for radix sort to O(nk) not O(n+k). I can't read charts.

oginer + 1 comment You're right. His solution is actualy more lazy than clever (assuming he uses an already implemented sort functin).

You don't need to store the students time in an array, though. You just count the ones entering in time as you read the input.

Rouby + 2 comments `foreach(var answer in Enumerable .Range(0, int.Parse(Console.ReadLine())) .Select(i => new { p = Console.ReadLine().Split(' ').Select(s => int.Parse(s)), s = Console.ReadLine().Split(' ').Select(s => int.Parse(s)) }) .Select(a => a.s.Count(t => t <= 0) < a.p.Last() ? "YES" : "NO")) Console.WriteLine(answer);`

C#'s Linq is really made to be lazy :p

jleach + 1 comment `Console.WriteLine(((Array.FindAll(a, x => x <= 0)).Length >= k ? "NO" : "YES"));`

Basically the same, predicates vs LINQ

vasilij_kolomie1 + 0 comments `print( "YES" if sum([1 for x in a if x<=0 ])<k else "NO")`

GyMbo + 1 comment This is my one liner with Linq:

Console.WriteLine(a.Aggregate(0,(x,y)=>y>0?x:x+1)< k?"YES":"NO");

roberto4 + 1 comment And mine, like someone said, too easy with linq.

Console.WriteLine(a.Where(i => i <= 0).Count() < k ? "YES" : "NO");

Really the way to do it is to not build an array and just count and write yes once you reach k items at <= 0.

dtl01 + 0 comments Count() accepts a predicate, too:

Console.WriteLine(a.Count(x => x<=0) < k ? "YES":"NO");

cesarjom + 2 comments The best sorting algorithm is done in O(nlogn) time; eg library Array.Sort() in C# uses a quicksort alg I beleive. The original problem can be solved in linear time, ie O(n). Therefore sorting would decrease performance as your # of students (n) increased.

rahulsup30 + 1 comment [deleted]rahulsup30 + 3 comments it is an o(n) solution

#include <cmath> #include <cstdio> #include <vector> #include <iostream> #include <algorithm> using namespace std; int main() { int t; cin>>t; while(t--) { int n,k,count=0; cin>>n>>k; for(int i=0;i<n;i++) { int x; cin>>x; if(x<=0) count++; } if(count>=k) cout<<"NO"<<endl; else cout<<"YES"<<endl; } return 0; }

parthkumarpatel + 0 comments [deleted]hackernitp + 5 comments int main(){ int t; cin >> t; for(int a0 = 0; a0 < t; a0++){ int n;

int k; int q=0; cin >> n >> k;`for(int a_i = 0;a_i < n;a_i++){ int d; cin >>d; if(d<=0) q++;} if(q<k) cout<<"YES"<<endl; else cout<<"NO"; } this is my code.can you tell what is wrong with this code? it is not clearing all the test cases.`

Revenge_01 + 0 comments [deleted]positivedeist_07 + 0 comments Initialize q=0 again just below the for loop (maybe before cin>>d). q value becomes altered after one iteration. So u have to keep it to q=0.

malaya + 0 comments YOU need a newLine after the "NO" to match the expected output

last line should be : cout << "NO" << endl;

rvrishav7 + 0 comments int t,c=0,i,k,j,n; cin>>t; if(t>=1&&t<=10) { for(i=1;i<=t;i++) { c=0; cin>>n>>k; if((n>=1)&&(n<=1000)&&(n>=k)) { int ar[n]; for(j=0;j>ar[j];

`if(ar[j]<=0) {c=c+1;} } if(c>=k) {cout<<"NO"<<endl;} if(c<k) {cout<<"YES"<<endl;} }}} try my code`

rvrishav7 + 0 comments int t,c=0,i,k,j,n; cin>>t; if(t>=1&&t<=10) { for(i=1;i<=t;i++) { c=0; cin>>n>>k; if((n>=1)&&(n<=1000)&&(n>=k)) { int ar[n]; for(j=0;j>ar[j];

`if(ar[j]<=0) {c=c+1;} } if(c>=k) {cout<<"NO"<<endl;} if(c<k) {cout<<"YES"<<endl;} }}}`

rvrishav7 + 0 comments int t,c=0,i,k,j,n; cin>>t; if(t>=1&&t<=10) { for(i=1;i<=t;i++) { c=0; cin>>n>>k; if((n>=1)&&(n<=1000)&&(n>=k)) { int ar[n]; for(j=0;j>ar[j];

`if(ar[j]<=0) {c=c+1;} } if(c>=k) {cout<<"NO"<<endl;} if(c<k) {cout<<"YES"<<endl;} }}}`

profnandaa + 1 comment I agree, a for loop or a simple filter will do O(n):

function angryProfessor(k, a) { const t = a.filter(i => i <= 0) return t.length >= k ? 'NO' : 'YES' }

akramrizwan8 + 0 comments thats the beauty of javascript

ajaycarnet + 2 comments Any Suggestions to improve this code?

My Code in C#:

`int t = Convert.ToInt32(Console.ReadLine()); for (int a0 = 0; a0 < t; a0++) { string[] tokens_n = Console.ReadLine().Split(' '); int n = Convert.ToInt32(tokens_n[0]); int k = Convert.ToInt32(tokens_n[1]); string[] a_temp = Console.ReadLine().Split(' '); int[] a = Array.ConvertAll(a_temp, Int32.Parse); int present = 0; if (k>n) { Console.WriteLine("YES"); } else { for(int i =0; i<n;i++) { if(a[i]<=0) { present++; } } if (present<k) { Console.WriteLine("YES"); } else { Console.WriteLine("NO"); } } }`

g_souvik04 + 0 comments 'k' would never be greater than 'n'. So, you may need to avoid checking- if (k>n)

igost + 0 comments use linq:

static void Main(String[] args) { int t = Convert.ToInt32(Console.ReadLine()); for(int a0 = 0; a0 < t; a0++){ string[] tokens_n = Console.ReadLine().Split(' '); int n = Convert.ToInt32(tokens_n[0]); int k = Convert.ToInt32(tokens_n[1]); string[] a_temp = Console.ReadLine().Split(' '); int[] a = Array.ConvertAll(a_temp,Int32.Parse); int i = a.Count(x => x <= 0); if (i >= k) { Console.WriteLine("NO"); } else { Console.WriteLine("YES"); } } }

diwserala + 0 comments [deleted]diwserala + 0 comments Since for this challenge we have to iterate n time while taking the input, I think it would be better to do the calculations while also reading the input at the same time.

skiv1989 + 0 comments If you want to understand complexity you can read this article: https://fromzerotoherojava.wordpress.com/2016/12/07/how-to-measure-algorithm-complexity-part-1/

saiful007 + 0 comments sorting is not good idea for this problem

we can solve the problem without sorting in O(n)

for (int i=0; i

sean_novick + 0 comments I agree. Sorting would actually be O(n log n). I just iterate through, count the students who are on time and compare with K. However, I do like the a[k - 1] idea.

piyus + 12 comments i dont think array is required , u can space optimize it i feel , check this out passes all the test case

public class Solution {

`public static void main(String[] args) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); for(int i=0;i<t;i++) { int n=sc.nextInt(); int k=sc.nextInt(); int count=0; for(int j=0;j<n;j++) { int temp=sc.nextInt(); if(temp<=0) count++; } if(count>=k) System.out.println("NO"); else System.out.println("YES"); } }`

}

Akbaaar + 2 comments we have almost same code here, but why my code didnt pass when it submitted. Do you kno why?

public static void main(String[] args) { Scanner scan = new Scanner(System.in); int roll,n,k,x;

`roll = scan.nextInt(); for (int i = 0; i < roll; i++) { n = scan.nextInt(); k = scan.nextInt(); int countPos=0; for (int j = 0; j < n; j++) { x = scan.nextInt(); if (x<=0) countPos++; } if (countPos>=k) System.out.println("No"); else System.out.println("Yes"); } }`

Rouby + 2 comments Case sensitive? YES vs Yes?

Akbaaar + 1 comment ouch, that's must be kidding... it works now, thx

VeeramRavi + 1 comment Too funny Rouby.... In Java when something in double quotes for example "xxxx" that means it's just a string. That too it's in print line, So it won't check for Case Sensitive or Case insensitive. All it do is it just prints what ever we gives in S.o.p line... Cheers

karzio + 0 comments I don't think you understood. It's not about Java compilator checking anything, it's about author of the problem wanting "YES" and not "Yes".

GMacias + 0 comments Rouby - THank you for that. I was getting irritated when I couldn't figure that out on mine too. haha

ariesuno + 0 comments im sorry, i made the same code but with an array, and i only passed the first test case. then i replace my array with an int variable, just like you did here and i passed the first test case. can you help me?

Pd: im from argentina, im sorry about my english

ashishkapil + 1 comment # piyus

hey, i ran your same code in C, buy only first testcase is passing. This is my code,could you pleases help with this.

int main() { int i,j,t,n,k,count=0,temp; scanf("%d",&t); for(i=0;i=k) printf("NO\n"); else printf("YES\n"); } return 0; }

piyus + 1 comment bro i am not being able to see the logic of your code , check ur comment once :)

ashishkapil + 0 comments oops!sorry ,i found my mistake. BTW thanks a lot for solution :)

AishwaryaA11 + 1 comment Thanks a lot. I did the same with an array and it gave me a segmentation fault for a few test cases. This one works just fine. Cheers!

piyus + 0 comments Good that it worked , happy coding. Cheers !

ujjwal_deswal + 0 comments int main(){ int t; cin >> t; for(int i = 0; i < t; i++) {int n[i]; int k[i]; cin >> n[i] >> k[i];//cout<< n[i]<> a[j]; } /* for(int j = 0;j < n[i];j++) { cout<0) { count++;} else count2++;}//cout<=k[i]) { cout<<"NO\n";} else { cout<<"YES\n";} } return 0; }

salil9992 + 0 comments You can remove the "check" variable and just compare against 0 using k:

int main(){ int t; cin >> t; for(int a0 = 0; a0 < t; a0++){ int n; int k; cin >> n >> k; vector<int> a(n); for(int a_i = 0;a_i < n;a_i++){ cin >> a[a_i]; } // Subtract from K if student is ON time for(int i = 0; i < n; ++i) { if(a[i] <= 0) { // STUDENT ON TIME --k; } } if(k <= 0) { cout << "NO" << endl; } else { cout << "YES" << endl; } } return 0; }

diwserala + 0 comments I think I did the same except I reduced one variable in use. :)

import java.io.*; import java.util.*; public class Solution { public static void main(String[] args) { /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */ Scanner in = new Scanner(System.in); int t = in.nextInt(); int n = 0; int k = 0; int currentInTime = 0; for(int i =0; i<t; i++){ n = in.nextInt(); k = in.nextInt(); for(int j = 0; j < n; j++){ if(in.nextInt() <= 0){ k -= 1; } } if(k <= 0){ System.out.println("NO"); } else { System.out.println("YES"); } } } }

19soumikrakshi96 + 0 comments Your solution is very good. This is exactly how I solved the problem.

manee_b + 0 comments yah i used the same way and it's working :D

amandhingra00 + 0 comments Did almost the same thing. Just that i didnt use

**count**and decremented**k**instead. Later checked if k was 0 or less than 0. Also, didnt store the nextInt() variable at all :Dkencluff + 0 comments Nice. Pretty much identical to mine though I don't bother with reading the number of test cases:

public static void main(String[] args) { Scanner in = new Scanner(System.in); in.nextLine(); // skip num testcases while ( in.hasNextInt() ) { int n=in.nextInt(); int k=in.nextInt(); int o = 0; for ( int i=0 ; i<n ; i++) if ( in.nextInt() <= 0 ) o++; System.out.println( o >=k ? "NO":"YES"); } }

jay209 + 0 comments [deleted]nandinisomani1 + 2 comments I wrote exactly the same code but only the first case passed, rest didn't. Can you tell me why?

public class Solution {

`public static void main(String[] args) { Scanner in = new Scanner(System.in); int t = in.nextInt(); int count=0; for(int a0 = 0; a0 < t; a0++) { int n = in.nextInt(); int k = in.nextInt(); int a[] = new int[n]; for(int i=0; i < n; i++) { a[i] = in.nextInt(); if(a[i]<=0) count++; } if(count>=k) System.out.println("NO"); else System.out.println("YES"); } }`

}

sandeepn161228 + 0 comments [deleted]sandeepn161228 + 0 comments You need to reset your count inside the second for loop[.]

dilantha_prasan1 + 0 comments wow that's great !!!

Dinesh1306 + 0 comments There is no need to short the array, just declare an integer variable say count=0 and than analyse if the time is <=0 increase the value of the count variable by one else leave it.

Now at the end justcheck whether

`count>=k`

or`count<k`

and accordingly output the answer. This will take very less time and memory.mikelane + 0 comments The complexity gets much worse, however, since the sort is

`O(n lg n)`

in the best case.alfonso_delamor1 + 0 comments string angryProfessor(int k, vector <int> a) { // Complete this function sort(a.begin(),a.end()); if(a[k - 1] > 0) {return "YES";} else return "NO"; }

Cypher713_net + 0 comments 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.

rokanor + 0 comments that is a cool way of thinking about the problem! Not optimal, but elegant++

mkansari + 0 comments we don't need to sort. The following code will always run for less than n times.

`int size = a.size(); for (int i=0; i<size && k>0; i++) { if (a[i]<=0) { k--; } } if (k==0) return "NO"; else return "YES";`

kd821 + 0 comments I appreciate your thinking on this problem but your time complexity would 0(nlogn) if we sort it and then check the starting elements until they are greater than 0. This doesn't matter for small inputs but it really does when the input grows too large.So the best approach would be read the array and count the number of students who are on time i.e whose arrival times<=0 and return based on the K(max threshold) value.

sanan_fataliyev + 0 comments yes, easier, but sorting is not cheap.

AD9000 + 0 comments But if you solve without sorting, you dont even need to take in the whole input... and end up solving in O(n) time.

(java 8 solution)

k: the threshold number of students

a: an array of integers representing arrival times

`static String angryProfessor(int k, int[] a) { for (int i = 0; i < a.length; i++) { if (a[i] <= 0) { k--; } if (k == 0) { return "NO"; } } return "YES"; }`

Kanahaiya + 0 comments Your approach is correct but it will take O(nlogn) time due to sorting but same thing can be achieved in O(n) time.

Here is the video explaination of my solution in O(n) time - https://youtu.be/3hvzKDJQypI

and you can find most of the hackerrank solutions with video explaination here- https://github.com/Java-aid/Hackerrank-Solutions

and many more needs to be addeed.

Regards,

Kanahaiya Gupta

Git Hub URL | https://github.com/Java-aid/

LIKE US | https://www.facebook.com/javaaid/

SUBSCRIBE US | https://www.youtube.com/channel/UCx1hbK753l3WhwXP5r93eYA

narutoitachi329 + 1 comment Time Complexity of T test are also added in it ,it become more time complex than O(T.(N))

Kanahaiya + 1 comment Yes if you are considering testcases also then compexity would be O(T*N). and for every solution if you are testing on T testcase then every solution complexity has to multiply by T. Even constant time complexity would become O(T) due to test case.

We measure compexity based on number of input not by the number of testcases.

narutoitachi329 + 1 comment But ,if we solve it by sorting it than compexity always be greater than O(N). that is i was taking about, thanks you for giving me idea about considering compexity without testcase in such problem ,thanks you again .

1)Can you give me some tip to start with DP and Complex Math problems ? 2)Where are from ?(state //college //city) BTW my soln is as follow ,we also can use single int instead of array ,that i used here

#include <bits/stdc++.h> using namespace std; int main() { int t; int n,k,c1; cin>>t; for(auto i=0;i<t;i++) { c1=0; cin>>n>>k; int arr[n]; for(auto j=0;j<n;j++) cin>>arr[j]; for(auto j=0;j<n;j++) { if(arr[j]<=0) c1++; } // cout<<c1<<endl; if(c1>=k) cout<<"NO"<<endl; else cout<<"YES"<<endl; } }

Kanahaiya + 1 comment Hi narutoitachi329,

May be, I have misunderstood your comment, I thought you are talking about my solution which i have provided in tutorial but i think you were refering to @AD9000 solution.

and thanks a lot for your compliment. :)

now i come to your query- 1) DP needs practice -practice practice even i also struggle with DP problems which is very common but will recommand to go through one book "

**Dynamic Programming for Coding Interviews: A Bottom-Up Approach to Problem Solving**"It may not be awesome book but this is what i have read and got some useful information about DP. and for math problem you can try euler project.

I am not much familer with c++. but could not understand your query that you are referring to int instead of array??

narutoitachi329 + 1 comment Thanks a lot for suggesting a book, HAPPY CODING To you BIG BRO

Kanahaiya + 0 comments Thanks brother.

Kanahaiya + 0 comments Hi,

Your solution is good and simlpe but it will take O(nlogn) time due to sorting which can be optimized further to O(n).

Here is the video explaination of my solution in O(n) time -

infracookies + 3 comments 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".

skkar_2k2 + 1 comment That's true, even I have the same problem. However I just took a pen and paper and defined the meaning of those variables. Moreoever, in program you can put a comment with valid identier for those variabels. It will resolve your problem. Always the best part is getting the positive points from a complex environment :)

isloat + 1 comment You can rename the variables in the code and the tests won't care about that.

As long as your output matches expected output, your code will pass tests.

skkar_2k2 + 2 comments Dear isloat,

This is about the variables used in the question not in the code. If you look at the question, it uses the sort of variables which are bit confused to put the solution as per the question.

petros_ziogas + 0 comments I agree with this strongly. Here we are teaching new programmers that is a good idea to call the array of student arrival times "a". Really?

I understand this time of variable naming is used a lot by programmers that want to create that one slick one-liner, but programming should be more than that. Other people will read you code. Give them a break and don't use "a" as a variable name.

condrint + 0 comments I agree. The absolute worst part of HR. Luckily, HR has really nice organization/tracking of your progress.

Himanshu21093 + 9 comments I am able to pass only first testcase. Any help guys?

abhilashswarup + 12 comments my guess is u are not clearing the variable that keeps the count of the number of students present between each test case.

haridevc + 0 comments Thanks.

yashwanth595 + 1 comment thanx

mdzubairkhan + 1 comment thanks it helped me too!!

tjagadeesh456 + 0 comments Thank You

sri41195 + 0 comments thank u

nish17 + 0 comments Thanks, I did the same mistake.

zayed123 + 0 comments Thank u so much..i was wondering why is only 1 test of mine is correct when its so simple problem..appreciate

AnmolAV + 0 comments Thanks man!

puneet079 + 0 comments Loads of thanks.

mandalsambeet + 1 comment how to clear that counter variable after each test case?

sethupavan + 0 comments initiate the variable to zero at starting of test case loop

onthehiddenjxn + 0 comments great help!

rishi11 + 0 comments oh my god thanks

yadavsumanpalsi1 + 0 comments thanks

pedrohfsd + 3 comments Testcase 2 has someone entering at time "0". Problem definition says: "If a student enters the class exactly when it starts (ai=0), the student is considered to have entered before the class has started." Make sure that students arriving at time 0 (time <= 0) are being accounted in your response.

Himanshu21093 + 0 comments Yeah, i figured that out. It was such a stupid mistake! Thanks folks! :)

codermoh3663 + 0 comments [deleted]sushmi95sushmit1 + 0 comments Yes,I have done it in the correct way.. yet only Test case#0 is passed.. Now what to do for the rest test cases..??

amazinghacker + 0 comments see editorial

ankur_sharma + 2 comments Use this solution in Java : easy and reliable

Scanner in = new Scanner(System.in);

int testcase = in.nextInt();

for(int i = 0; i < testcase; i++)

{

int N = in.nextInt();

int K = in.nextInt();

int count = 0;

while(N > 0)

{

int s = in.nextInt();

if(s <= 0)

{

count++;

}

N--;

}

if(count >= K)

System.out.println("NO");

else

System.out.println("YES");

}

ash_upadhyay + 0 comments Great!! used only one variable and problem solved. Nice work ankur :)

himani2309 + 0 comments What about given Constraints?

kangkanlahkar1 + 0 comments [deleted]prashaaant + 0 comments [deleted]sarojkumar_rout + 0 comments [deleted]Saurabh_Sawant + 0 comments u r genious

balyan + 0 comments i guess you are printing YES and NO in opposite cases.

murali_d + 6 comments 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')`

seanjohnsen96 + 0 comments Had a similar solution. Python's great :)

wittrup + 1 comment `#!/bin/python3 for _ in range(int(input())): print(["NO","YES"][int(input().split()[1])>len([x for x in map(int, input().split())if x<1])])`

beckwithdylan + 0 comments beautiful

guptaayush241 + 0 comments You can use lambda too!

LeHarkunwar + 0 comments Did it similarly

for _ in range(int(input())): n,k = map(int,input().split()) a = [x for x in map(int,input().split()) if x<=0] print("YES" if len(a)<k else "NO")

alison_thaung + 0 comments If you want to cut down some processing time, here's a similar approach using bool instead of a temporary list

print("NO" if k <= sum(x <= 0 for x in a) else "YES" )

vedantasingh28 + 1 comment 10 7 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

apolo4pena + 0 comments [deleted]

gregwwolff + 3 comments javascript one-liner

console.log(a.filter(x=>x<=0).length < k ? "YES" : "NO");

ashoksoftboy + 0 comments output is

YES undefined NO undefined

ndsvw + 0 comments exactly what I got. But it's only 1 line because main() is already pre-implemented by hackerrank ;)

jessica_nations + 1 comment Wrong Answer :( undefined

gregwwolff + 0 comments problem has changed, but with javascript you can still do:

return a.filter(x=>x<=0).length < k ? "YES" : "NO";

gaspareb + 0 comments Your answers are not correct for test case 1, my code is failing even though it performs a no on this case.

`int k = 7; int a[] = {26,94,-95,34,67,-97,17,52,1,86}; You have this as cancelled. You can clearly see that there are 8 positive and 2 late therefore the answer is and should be NO, that the class is not cancelled. Can you please explain why you have it marked as YES?`

sulaimanr29 + 0 comments python

lisst=[] for i in a: if i<1: lisst.append(i) x=len(lisst) if x>=k: return 'NO' else: return 'YES'

Kanahaiya + 0 comments Hello friends,

In this video, I have explained hackerrank angry professor solution algorithm. hackerrank angry professor problem can be solved by using one for loop. The complexity of angry professor hackerrank solution is O (n).

If interested to know more about the generic algorithm in details-

click here for the

**video explanation of generic algorithm**with complexity analysis.or you can click on the image too to follow youtube tutorial.

**Here is the working solution:-****source code :**static String angryProfessor(int k, int[] a) { int count = 0; for (int i = 0; i < a.length; i++) { if (a[i] <= 0) { count++; } } return ((count >= k) ? "NO" : "YES"); }

Would really appreciate your feedback like, dislike , comment etc. on my video.

# Do not forget to upvote, if you find it useful.

karthikmakwana53 + 0 comments here its code in c++

class kk

{

private:

`int arr[10000],num,i,counter,student;`

public:

`void read() { // cout<<" ENTER HOW MANY NUMEBR TO BE ENTER : "; cin>>num; //cout<<" STUDENT TO BE ALLOW : "; cin>>student; for(i=1;i<=num;i++) { // cout<<" ENTER NUMBER "<<i<<" : "; cin>>arr[i]; } } void compute() { counter=0; for(i=1;i<=num;i++) { if(arr[i]<=0) { counter++; } } } void display() { if(counter>=student) { cout<<"NO"; } if(counter<student) { cout<<"YES"; } }`

};

int main()

{

`class kk obj; int num,i;`

// cout<<" TEST CASES : ";

`cin>>num; for(i=1;i<=num;i++) { obj.read(); obj.compute(); obj.display(); cout<<"\n"; } return 0;`

}

Sort 749 Discussions, By:

Please Login in order to post a comment