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
- Binary Tree
- 구현
- Stack
- two pointers
- Matrix
- 자바
- Class
- 파이썬
- bit manipulation
- greedy
- dynamic programming
- geometry
- Method
- Counting
- database
- Binary Search
- 코딩테스트
- java
- 코테
- array
- sorting
- Tree
- SQL
- string
- simulation
- Data Structure
- implement
- Number Theory
- Math
- hash table
Archives
- Today
- Total
코린이의 소소한 공부노트
[LeetCode/Easy] 448. Find All Numbers Disappeared in an Array 본문
1. Input
1) int 배열 nums
2) nums의 요소의 범위는 [1, nums.length]이다.
2. Output
1) [1, nums.length] 범위의 정수 중 nums에 없는 숫자들을 담은 List
3. Constraint
1) 1 <= nums.length <= 10^5
2) 1 <= nums[i] <= n
4. Example
Input: nums = [4,3,2,7,8,2,3,1] -> Output: [5,6]
5. Code
1) 첫 코드(2022/12/25)
import java.util.*;
int[] count = new int[nums.length];
for(int i=0 ; i<nums.length ; i++)
count[nums[i]-1]++;
List<Integer> list = new ArrayList<Integer>();
for(int i=0 ; i<count.length ; i++)
if(count[i]==0) list.add(i+1);
return list;
'코딩테스트 풀이 > JAVA' 카테고리의 다른 글
[LeetCode/Easy] 1475. Final Prices With a Special Discount in a Shop (0) | 2022.12.26 |
---|---|
[LeetCode/Easy] 1470. Shuffle the Array (0) | 2022.12.26 |
[LeetCode/Easy] 441. Arranging Coins (0) | 2022.12.25 |
[LeetCode/Easy] 1464. Maximum Product of Two Elements in an Array (0) | 2022.12.25 |
[LeetCode/Easy] 1455. Check If a Word Occurs As a Prefix of Any Word in a Sentence (0) | 2022.12.25 |