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 | 31 |
Tags
- implement
- java
- Method
- array
- SQL
- string
- Binary Tree
- 코테
- hash table
- Stack
- 구현
- geometry
- Matrix
- Binary Search
- 자바
- dynamic programming
- simulation
- 코딩테스트
- bit manipulation
- 파이썬
- sorting
- Math
- database
- Number Theory
- Tree
- Class
- greedy
- Counting
- Data Structure
- two pointers
Archives
- Today
- Total
코린이의 소소한 공부노트
[프로그래머스/Lv.0] 삼각형의 완성조건 (1) 본문
1. Input
1) 삼각형의 세 변의 길이가 담긴 배열 sides
2. Output
1) 세 변으로 삼각형을 만들 수 있다면 1을, 만들 수 없다면 2를 반환
2) 가장 긴 변의 길이는 다른 두 변의 길이의 합보다 작아야 삼각형이 완성됨
3. Constraint
1) sides의 원소는 자연수
2) sides의 길이는 3
3) 1 ≤ sides의 원소 ≤ 1000
4. Example
Input: sides={1,2,3} -> Output: 2
Input: sides={3,4,5} -> Output: 1
설명:
- 1 + 2 = 3 이므로 삼각형이 될 수 없다.
- 3 + 4 > 5 이므로 삼각형이 될 수 있다.
5. Code
1) 첫 코드(2022/10/25)
import java.util.Arrays;
// main()
Arrays.sort(sides);
return sides[0]+sides[1]>sides[2] ? 1 : 2;
'코딩테스트 풀이 > JAVA' 카테고리의 다른 글
[프로그래머스/Lv.0] 가까운 수 (0) | 2022.10.28 |
---|---|
[프로그래머스/Lv.0] 컨트롤 제트 (0) | 2022.10.28 |
[프로그래머스/Lv.0] 중복된 문자 제거 (0) | 2022.10.28 |
[프로그래머스/Lv.0] 배열 원소의 길이 (0) | 2022.10.28 |
[프로그래머스/Lv.0] 소인수분해 (0) | 2022.10.27 |