Skip to content
Programmingoneonone
Programmingoneonone

Learn everything about programming

  • Home
  • CS Subjects
    • Internet of Things (IoT)
    • Digital Communication
    • Human Values
    • Cybersecurity
  • Programming Tutorials
    • C Programming
    • Data structures and Algorithms
    • 100+ Java Programs
    • 100+ C Programs
  • HackerRank Solutions
    • HackerRank Algorithms Solutions
    • HackerRank C problems solutions
    • HackerRank C++ problems solutions
    • HackerRank Java problems solutions
    • HackerRank Python problems solutions
Programmingoneonone
Programmingoneonone

Learn everything about programming

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 *

Are you a student and stuck with your career or worried about real-time things, and don't know how to manage your learning phase? Which profession to choose? and how to learn new things according to your goal, and land a dream job. Then this might help to you.

Hi My name is YASH PAL, founder of this Blog and a Senior Software engineer with 5+ years of Industry experience. I personally helped 40+ students to make a clear goal in their professional lives. Just book a one-on-one personal call with me for 30 minutes for 300 Rupees. Ask all your doubts and questions related to your career to set a clear roadmap for your professional life.

Book session - https://wa.me/qr/JQ2LAS7AASE2M1

Pages

  • About US
  • Contact US
  • Privacy Policy

Follow US

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