Skip to content
Programmingoneonone
Programmingoneonone
  • Engineering Subjects
    • Internet of Things (IoT)
    • Digital Communication
    • Human Values
  • Programming Tutorials
    • C Programming
    • Data structures and Algorithms
    • 100+ Java Programs
    • 100+ C Programs
    • 100+ C++ Programs
  • Solutions
    • HackerRank
      • Algorithms Solutions
      • C solutions
      • C++ solutions
      • Java solutions
      • Python solutions
    • Leetcode Solutions
    • HackerEarth Solutions
  • Work with US
Programmingoneonone
Programmingoneonone

HackerRank Angry Professor problem solution

YASH PAL, 31 July 202430 November 2025

In this HackerRank Angry Professor problem you have Given the arrival time of each student and a threshold number of attendees, determine if the class is canceled.

hackerrank angry professor problem solution

Problem solution in Python programming.

T = int(input())
for _ in range(T):
    N, K = input().split()
    N = int(N)
    K = int(K)
    students = 0
    arrivals = input().split()
    for i in arrivals:
        if int(i) <= 0:
            students += 1
    if students < K:
        print("YES")
    else:
        print("NO")

Problem solution in Java Programming.

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 scan=new Scanner(System.in);
		int T= scan.nextInt();
		for(int i=0; i<T; i++){
			int numofstudents=0;
			int N=scan.nextInt();
			int K=scan.nextInt();
			for(int j=0;j<N; j++){
				int a= scan.nextInt();
				if( a<=0) numofstudents++;
			}
			if(numofstudents < K) System.out.println("YES");
			else System.out.println("NO");
    }
}
}

Problem solution in C++ programming.

#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a; cin >> a;
    for (int g=0; g<a; g++)
    {
        int b,c; cin >> b >> c;
        int num=0; 
        for (int g=0; g<b; g++)
        {
            int d; cin >> d;
            if (d<=0) num++; 
        }
        if (num>=c)
        {
            cout << "NO" << 'n'; 
        }
        else cout << "YES" << 'n';
    }
    return 0; 
}

Problem solution in C programming.

#include<stdio.h>
#include<stdlib.h>

int main(){
	int i, j , T, N, K, t, counter;
	scanf("%d",&T);
	for(i=0; i<T; i++){
		counter= 0;
		scanf("%d %d",&N,&K);
		//t = malloc(sizeof(int)*N);
		for(j=0; j<N; j++){
			scanf("%d",&t);
			if(t<=0) counter++;
		}
		if(counter < K)printf("YESn");
		else printf("NOn");
	}
	return 0;
}

Problem solution in JavaScript programming.

function processData(input) {
    //Enter your code here
    var res = "No";
    var lines = input.split('n');
    lines.shift(1);
    for(var i = 0; i < lines.length; i += 2) {
      var currentLine = lines[i].split(" ");
      var nextLine = lines[i+1].split(" ");
      var latePeople = 0;
      if(nextLine.length != currentLine[0]){
        process.stdout.write("NOn");
      } else {
          for(var j = 0; j < nextLine.length; j++) {
              if(nextLine[j] > 0) {
                  latePeople++;
              }
          }
          if((currentLine[0] - latePeople) >= currentLine[1]){
                  process.stdout.write("NOn");
          } else {
                  process.stdout.write("YESn");
          }
      }
    } 

} 

process.stdin.resume();
process.stdin.setEncoding("ascii");
_input = "";
process.stdin.on("data", function (input) {
    _input += input;
});

process.stdin.on("end", function () {
   processData(_input);
});

Algorithms coding problems solutions AlgorithmsHackerRank

Post navigation

Previous post
Next post

Leave a Reply

Your email address will not be published. Required fields are marked *

Programmingoneonone

We at Programmingoneonone, also known as Programming101 is a learning hub of programming and other related stuff. We provide free learning tutorials/articles related to programming and other technical stuff to people who are eager to learn about it.

Pages

  • About US
  • Contact US
  • Privacy Policy

Practice

  • Java
  • C++
  • C

Follow US

  • YouTube
  • LinkedIn
  • Facebook
  • Pinterest
  • Instagram
©2026 Programmingoneonone | WordPress Theme by SuperbThemes