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
- sorting
- Binary Search
- implement
- 코테
- geometry
- database
- Stack
- array
- Matrix
- greedy
- simulation
- two pointers
- 자바
- Counting
- Binary Tree
- Tree
- string
- 파이썬
- 코딩테스트
- 구현
- dynamic programming
- Method
- Data Structure
- bit manipulation
- SQL
- hash table
- Class
- java
- Math
- Number Theory
Archives
- Today
- Total
코린이의 소소한 공부노트
[LeetCode/Easy] 2057. Smallest Index With Equal Value 본문
1. Input
1) 정수 배열 nums
2. Output
1) i%10==nums[i]를 만족하는 가장 작은 i를 반환
2) 그런 인덱스가 없다면 –1을 반환
3. Constraint
1) 1 <= nums.length <= 100
2) 0 <= nums[i] <= 9
4. Example
Input: nums = [4,3,2,1] -> Output: 2
설명:
- i=0: 0%10 = 0 != nums[0]
- i=1: 1%10 = 1 != nums[1]
- i=2: 2%10 = 2 == nums[2]
- i=3: 3%10 = 3 != nums[3]
- 같은 것은 2뿐이므로 2를 반환한다.
5. Code
1) 첫 코드(2022/06/23)
for(int i=0 ; i<nums.length ; i++)
if(i%10==nums[i])
return i;
return -1;
'코딩테스트 풀이 > JAVA' 카테고리의 다른 글
[LeetCode/Easy] 2089. Find Target Indices After Sorting Array (0) | 2023.01.12 |
---|---|
[LeetCode/Easy] 2068. Check Whether Two Strings are Almost Equivalent (0) | 2023.01.12 |
[LeetCode/Easy] 2042. Check if Numbers Are Ascending in a Sentence (0) | 2023.01.12 |
[프로그래머스/Lv.1] 푸드 파이트 대회 (0) | 2023.01.11 |
[LeetCode/Easy] 100. Same Tree (0) | 2023.01.11 |