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
- Data Structure
- database
- two pointers
- Binary Tree
- Binary Search
- Tree
- bit manipulation
- Matrix
- 구현
- sorting
- greedy
- Counting
- hash table
- Method
- dynamic programming
- simulation
- array
- 자바
- geometry
- SQL
- string
- Stack
- implement
- Class
- Number Theory
- 파이썬
- java
- 코딩테스트
- 코테
- Math
Archives
- Today
- Total
코린이의 소소한 공부노트
[프로그래머스/Lv.1] 짝수와 홀수 본문
1. Input
1) 정수 num
2. Output
1) num이 짝수라면 “Even”, 홀수라면 “Odd”를 반환
3. Constraint
1) num은 int 범위의 정수
2) 0은 짝수
4. Example
Input: num=3 -> Output: “Odd”
5. Code
1) 첫 코드(2022/??)
String answer = "Even";
if(Math.abs(num%2) == 1)
answer = "Odd";
return answer;
2) 간결하게 바꾼 코드(2022/11/24)
return Math.abs(num%2) == 1 ? "Odd" : "Even";
'코딩테스트 풀이 > JAVA' 카테고리의 다른 글
[프로그래머스/Lv.1] 정수 제곱근 판별 (0) | 2022.11.24 |
---|---|
[프로그래머스/Lv.1] 제일 작은 수 제거하기 (0) | 2022.11.24 |
[프로그래머스/Lv.2] N개의 최소공배수 (0) | 2022.11.23 |
[프로그래머스/Lv.2] 피보나치 수 (0) | 2022.11.23 |
[프로그래머스/Lv.2] 최댓값과 최솟값 (0) | 2022.11.23 |