[JAVA | 백준 10818] 최대, 최소
· 테크· Java
Java
백준 10818번 www.acmicpc.net/problem/10818
풀이
Collection 으로 문제를 풀이했다. 정수형의 arraylist 를 만들어 배열을 받았고, Collection.max() 와 Collection.min() 메서드를 사용해서 최대, 최소를 구했다.
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
import java.util.*;
public class Main{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int x = sc.nextInt();
List<Integer> listArr = new ArrayList<>();
for (int i=0; i<x; i++) {
listArr.add(sc.nextInt());
}
int min = Collections.min(listArr);
int max = Collections.max(listArr);
System.out.println(min+" "+max);
sc.close();
}
}
|
cs |
Comments
No comments yet. Be the first!
319 posts in 테크
- 368Supabase 프로젝트 복사하기 (Restore to a New Project)NEW
- 341Migrating from Permanent Access Tokens to Token Exchange — Why Order Matters
- 326Startup & Product Glossary: Terms Every Solo Founder Should Know
- 325Context Management — How I Do It Now
- 324Claude Code Routines vs Cowork Schedule — What's the Difference?
1–5 / 319