Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- springboot 게시판만들기
- springboot 사이드프로젝트
- typescript 기초문법
- 유니티Material
- python 괄호 회전하기
- JS기초
- 파이썬 기초
- 스프링부트 미니프로젝트
- 스프링부트 블로그만들기
- 스프링부트 게시판만들기
- springboot 게시판
- 괄호 회전하기 파이썬
- 유니티Cube
- 타입스크립트 기초문법
- jpa 게시판
- 타입스크립트 기초
- 스프링부트 update
- 스프링부트 블로그
- spring jpa 사이드프로젝트
- 스프링부트 회원가입
- 유니티
- 파이썬 괄호 회전하기
- springboot 미니프로젝트
- springboot 게시판 프로젝트
- 스프링 게시판 만들기
- spring jpa 게시판
- 프로그래머스 괄호 회전하기 python
- 타입스크립트 기본문법
- 스프링게시판프로젝트
- 유니티기초
Archives
- Today
- Total
Digking's cave
해커랭크 Hackerrank ) Angry Professor 본문
728x90
https://www.hackerrank.com/challenges/angry-professor/problem?isFullScreen=true
Angry Professor | HackerRank
Decide whether or not the class will be canceled based on the arrival times of its students.
www.hackerrank.com
import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.function.*;
import java.util.regex.*;
import java.util.stream.*;
import static java.util.stream.Collectors.joining;
import static java.util.stream.Collectors.toList;
class Result {
/*
* Complete the 'angryProfessor' function below.
*
* The function is expected to return a STRING.
* The function accepts following parameters:
* 1. INTEGER k
* 2. INTEGER_ARRAY a
*/
public static String angryProfessor(int k, List<Integer> a) {
int yes = 0;
for (int i = 0; i < a.size(); i++) {
if(a.get(i) <= 0) {
yes++;
}
}
return yes < k ? "YES" : "NO";
}
}
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(System.getenv("OUTPUT_PATH")));
int t = Integer.parseInt(bufferedReader.readLine().trim());
IntStream.range(0, t).forEach(tItr -> {
try {
String[] firstMultipleInput = bufferedReader.readLine().replaceAll("\\s+$", "").split(" ");
int n = Integer.parseInt(firstMultipleInput[0]);
int k = Integer.parseInt(firstMultipleInput[1]);
List<Integer> a = Stream.of(bufferedReader.readLine().replaceAll("\\s+$", "").split(" "))
.map(Integer::parseInt)
.collect(toList());
String result = Result.angryProfessor(k, a);
bufferedWriter.write(result);
bufferedWriter.newLine();
} catch (IOException ex) {
throw new RuntimeException(ex);
}
});
bufferedReader.close();
bufferedWriter.close();
}
}
반응형
'코딩테스트 > 알고리즘' 카테고리의 다른 글
해커링크 HackerRank ) Staircase (0) | 2023.06.06 |
---|---|
해커랭크 Hackerrank ) Migratory Birds (0) | 2023.05.27 |
HackerRank 해커랭크 ) Mini-Max Sum (0) | 2023.05.25 |
프로그래머스 ) 대소문자 바꿔서 출력하기(Java) (0) | 2023.05.16 |
프로그래머스 ) 숫자짝꿍 (Python) (0) | 2022.10.24 |