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
- SQL
- 자바
- Matrix
- two pointers
- Class
- greedy
- Data Structure
- hash table
- bit manipulation
- Math
- Binary Search
- sorting
- dynamic programming
- Number Theory
- 코딩테스트
- Method
- Stack
- simulation
- Tree
- Counting
- Binary Tree
- java
- string
- implement
- geometry
- database
- 구현
- 파이썬
Archives
- Today
- Total
코린이의 소소한 공부노트
[LeetCode/Easy] 1346. Check If N and Its Double Exist 본문
1. Input
1) 정수 배열 arr
2. Output
1) 다음 규칙을 만족하는 인덱스 i와 j가 있으면 true, 없으면 false를 반환
2) 규칙
- i != j
- 0 <= i, j < arr.length
- arr[i] == 2 * arr[j]
3. Constraint
1) 2 <= arr.length <= 500
2) - 10^3 <= arr[i] <= 10^3
4. Example
Input: arr = [10,2,5,3] -> Output: true
설명: arr[0] == arr[2] * 2이므로 true를 반환한다.
5. Code
1) 첫 코드(2022/07/15)
for(int i=0 ; i<arr.length-1 ; i++){
for(int j=i+1 ; j<arr.length ; j++)
if(arr[i]==2*arr[j] || arr[i]*2==arr[j])
return true;
}
return false;
'코딩테스트 풀이 > JAVA' 카테고리의 다른 글
[LeetCode/Easy] 1365. How Many Numbers Are Smaller Than the Current Number (0) | 2022.12.24 |
---|---|
[LeetCode/Easy] 1351. Count Negative Numbers in a Sorted Matrix (0) | 2022.12.24 |
[LeetCode/Easy] 1342. Number of Steps to Reduce a Number to Zero (0) | 2022.12.24 |
[LeetCode/Easy] 1323. Maximum 69 Number (0) | 2022.12.24 |
[LeetCode/Easy] 1313. Decompress Run-Length Encoded List (0) | 2022.12.24 |