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 |
Tags
- 스프링부트 미니프로젝트
- spring jpa 게시판
- springboot 미니프로젝트
- 스프링 게시판 만들기
- 스프링부트 게시판만들기
- springboot 게시판 프로젝트
- 유니티기초
- 스프링부트 블로그
- python 괄호 회전하기
- 괄호 회전하기 파이썬
- springboot 게시판만들기
- spring jpa 사이드프로젝트
- 스프링부트 update
- 유니티Cube
- 스프링부트 회원가입
- JS기초
- springboot 사이드프로젝트
- 타입스크립트 기초
- typescript 기초문법
- 유니티
- 타입스크립트 기초문법
- 스프링부트 블로그만들기
- 파이썬 기초
- 프로그래머스 괄호 회전하기 python
- 파이썬 괄호 회전하기
- 유니티Material
- springboot 게시판
- 스프링게시판프로젝트
- jpa 게시판
- 타입스크립트 기본문법
Archives
- Today
- Total
Digking's cave
해커랭크 Hackerrank ) Migratory Birds 본문
728x90
https://www.hackerrank.com/challenges/migratory-birds/problem?isFullScreen=true
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 'migratoryBirds' function below.
*
* The function is expected to return an INTEGER.
* The function accepts INTEGER_ARRAY arr as parameter.
*/
public static int migratoryBirds(List<Integer> arr) {
Map<Integer,Integer> mapList = new HashMap<Integer,Integer>() {{
put(1,0);
put(2,0);
put(3,0);
put(4,0);
put(5,0);
}};
for (int i = 0; i < arr.size(); i++) {
mapList.put(arr.get(i),mapList.get(arr.get(i)+1));
}
int countList[] = new int[5];
for (int i : countList) {
countList[i] = mapList.get(i);
}
Arrays.sort(countList);
return countList[0];
}
}
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 arrCount = Integer.parseInt(bufferedReader.readLine().trim());
List<Integer> arr = Stream.of(bufferedReader.readLine().replaceAll("\\s+$", "").split(" "))
.map(Integer::parseInt)
.collect(toList());
int result = Result.migratoryBirds(arr);
bufferedWriter.write(String.valueOf(result));
bufferedWriter.newLine();
bufferedReader.close();
bufferedWriter.close();
}
}
반응형
'코딩테스트 > 알고리즘' 카테고리의 다른 글
해커링크 HackerRank ) Staircase (0) | 2023.06.06 |
---|---|
해커랭크 Hackerrank ) Angry Professor (0) | 2023.05.27 |
HackerRank 해커랭크 ) Mini-Max Sum (0) | 2023.05.25 |
프로그래머스 ) 대소문자 바꿔서 출력하기(Java) (0) | 2023.05.16 |
프로그래머스 ) 숫자짝꿍 (Python) (0) | 2022.10.24 |