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
- Binary Search
- Tree
- array
- hash table
- bit manipulation
- geometry
- Number Theory
- 자바
- string
- java
- Class
- Stack
- 구현
- two pointers
- 코테
- 파이썬
- SQL
- 코딩테스트
- Binary Tree
- greedy
- dynamic programming
- Counting
- implement
- Method
- Matrix
- database
- sorting
- Math
- simulation
Archives
- Today
- Total
코린이의 소소한 공부노트
[LeetCode/Easy] 2553. Separate the Digits in an Array 본문
1. Input
1) int[] nums
2. Output
1) nums의 모든 요소를 각 자리수로 쪼갠 후, 순서를 유지한 채로 그 숫자들을 담은 int[] 반환
- 요소가 321이라면 배열에 [3,2,1]이 담겨야 한다.
3. Constraint
1) 1 <= nums.length <= 1000
2) 1 <= nums[i] <= 10^5
4. Example
Input: nums = [13,25,83,77] -> Output: [1,3,2,5,8,3,7,7]
5. Code
1) 첫 코드(2023/03/08)
ArrayList<Integer> list = new ArrayList<Integer>();
for(int i : nums){
String s = String.valueOf(i);
for(int j=0 ; j<s.length() ; j++)
list.add(s.charAt(j)-'0');
}
int[] answer = new int[list.size()];
for(int i=0 ; i<list.size() ; i++)
answer[i] = list.get(i);
return answer;
'코딩테스트 풀이 > JAVA' 카테고리의 다른 글
[LeetCode/Easy] 645. Set Mismatch (0) | 2023.03.10 |
---|---|
[LeetCode/Easy] 643. Maximum Average Subarray I (0) | 2023.03.09 |
[백준 온라인 저지] 11718. 그대로 출력하기 (0) | 2023.03.07 |
[백준 온라인 저지] 9086. 문자열 (0) | 2023.03.07 |
[백준 온라인 저지] 2743. 단어 길이 재기 (0) | 2023.03.07 |