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
- array
- Tree
- Math
- implement
- 코테
- 코딩테스트
- database
- dynamic programming
- Method
- Binary Search
- greedy
- 자바
- Stack
- Class
- simulation
- two pointers
- sorting
- string
- Number Theory
- Counting
- Matrix
- Binary Tree
- java
- 파이썬
- hash table
- 구현
- Data Structure
- SQL
- geometry
- bit manipulation
Archives
- Today
- Total
코린이의 소소한 공부노트
[LeetCode/Easy] 1523. Count Odd Numbers in an Interval Range 본문
1. Input
1) 음이 아닌 정수 low
2) 음이 아닌 정수 high
2. Output
1) [low, high] 범위의 정수 중 홀수의 개수를 반환
3. Constraint
1) 0 <= low <= high <= 10^9
4. Example
Input: low = 3, high = 7 -> Output: 3
설명: 3부터 7까지의 수 중 홀수는 3, 5, 7의 3개다.
5. Code
1) 첫 코드(2022/07/19)
if(low%2!=0 && high%2!=0){
return (high-low+1)/2 +1;
}else{
return (high-low+1)/2;
}
'코딩테스트 풀이 > JAVA' 카테고리의 다른 글
[LeetCode/Easy] 1534. Count Good Triplets (0) | 2022.12.27 |
---|---|
[LeetCode/Easy] 1528. Shuffle String (0) | 2022.12.27 |
[LeetCode/Easy] 1512. Number of Good Pairs (0) | 2022.12.27 |
[LeetCode/Easy] 1507. Reformat Date (0) | 2022.12.27 |
[LeetCode/Easy] 1502. Can Make Arithmetic Progression From Sequence (0) | 2022.12.27 |