일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- ArrayList
- hashset
- coding
- 재귀함수
- leetcode
- 리트코드
- 부분배열
- programmers
- 알고리즘
- priority queue
- greedy
- 깊이우선탐색
- HashMap
- PCCP
- Java
- Algorithm
- recursion
- string
- DP
- binary tree
- dfs
- two pointers
- 브루트포스
- 우선순위 큐
- Array
- Today
- Total
목록Algorithm (53)
지식창고
문제 : int 배열 piles[] 가 주어지고 임의의 배열 한 원소에 operation을 k번 수행해서 가장 작은 배열의 합을 만드는 것. ※ 한 element에 operation이 여러 번 수행될 수 있다. operation = floor(piles[i] / 2) Input: piles = [5,4,9], k = 2 Output: 12 Explanation: Steps of a possible scenario are: - Apply the operation on pile 2. The resulting piles are [5,4,5]. - Apply the operation on pile 0. The resulting piles are [3,4,5]. The total number of stones i..
LeetCode 817. Linked List Components - Java 문제 : Linked List를 주고 그 Linked List의 subset을 준다. 주어진 Linked List를 기준으로 subset List가 순서대로 이어진 그룹이 몇 개인지 센다. Input: head = [0,1,2,3], nums = [0,1,3] Output: 2 Explanation: 0 and 1 are connected, so [0, 1] and [3] are the two connected components. [0, 1] , [3] -> 2 HashSet 생성 HashSet의 특징 : 중복을 허용하지 않는다. Set set = new HashSet(); nums를 HashSet에 추가한다. for(int..
Leetcode 791. Custom Sort String - Java 문제 : s에 있는 문자열을 order 기준으로 정렬 Input: order = "cba", s = "abcd" Output: "cbad" 문자열 s 에서 각 알파벳이 몇 번 나왔는지 count 배열에 저장해 관리한다. int[] cnt = new int[128]; for(char ch : s.toCharArray()) { cnt[ch]++; } 정렬의 기준이 되는 문자열 order에 알파벳을 빠짐없이 들어갈 수 있도록 더해준다. order += "abcdefghijklmnopqrstuvwxyz"; Output을 저장할 변수 result를 선언한다. order를 기준으로 cnt 배열을 확인하며 결과 값에 저장한다. for(char c..