Angry Professor HackerRank Algorithms Implementation
TIME O(N) [ArrayList Traversal]
SPACE O(1) [Only Constants Are Used]
public static String angryProfessor(int k, List<Integer> aa) {
int count=0;
for(int i=0;i<aa.size();i++){
if(aa.get(i)<=0){
count++;
}
}
if(count>=k){
// System.out.println("YES");
return "NO";
}
else{
// System.out.println("NO");
return "YES";
}
}
Thanks for reading.
Comments
Post a Comment