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

Popular posts from this blog

Solutions Of Practice Questions Dated 01-06-2022

CODEFORCES SPY DETECTED ROUND 713

Maximum Winning Score Geeks For Geeks