Skip to content
Programming101
Programmingoneonone
  • Home
  • CS Subjects
    • Internet of Things (IoT)
    • Digital Communication
    • Human Values
  • 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
Programming101
Programmingoneonone

HackerRank Angry Professor problem solution

YASH PAL, 31 July 2024

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

Post navigation

Previous post
Next post

Pages

  • About US
  • Contact US
  • Privacy Policy

Programing Practice

  • C Programs
  • java Programs

HackerRank Solutions

  • C
  • C++
  • Java
  • Python
  • Algorithm

Other

  • Leetcode Solutions
  • Interview Preparation

Programming Tutorials

  • DSA
  • C

CS Subjects

  • Digital Communication
  • Human Values
  • Internet Of Things
  • YouTube
  • LinkedIn
  • Facebook
  • Pinterest
  • Instagram
©2025 Programmingoneonone | WordPress Theme by SuperbThemes