Angry Professor - HackerRank || HackerRank Angry Professor Solution

Problem Name: Angry Professor
Judge: HackerRank
Problem link: Angry Professor



HackerRank Angry Professor Solution in C

#include <stdio.h>

int main()
{
    int t;
    scanf("%d", &t);
    for (int i = 0; i < t; i++)
    {
        int n, k, count = 0;
        scanf("%d %d", &n, &k);
        int array[n];
        for (int j = 0; j < n; j++)
        {
            scanf("%d", &array[i]);
            if (array[i] <= 0) count++;
        }
        if (count >= k) printf("NO\n");
        else printf("YES\n");
    }
    return 0;
}


HackerRank Angry Professor Solution in C++/Cpp

#include <bits/stdc++.h>

using namespace std;

int main()
{
    int t;
    cin >> t;
    for (int i = 0; i < t; i++)
    {
        int n, k, count = 0;
        cin >> n >> k;
        int array[n];
        for (int j = 0; j < n; j++)
        {
            cin >> array[i];
            if (array[i] <= 0) count++;
        }
        if (count >= k) cout << "No" << endl;
        else cout << "YES" << endl;
    }

    return 0;
}


HackerRank Angry Professor Solution in Java

import java.util.Scanner;

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





Next Post Previous Post
No Comment
Add Comment
comment url