일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- concurrency
- 생명주기
- View
- weak
- 클로저
- 안드로이드
- async
- 풀이
- 구조체
- 프로퍼티
- 연산자
- 백준
- 차이
- 리스트뷰
- ios
- 프래그먼트
- 옵셔널
- 프로그래머스
- Swift
- rx
- 스위프트
- RxSwift
- Subject
- observable
- noncopyable
- Self
- 자바
- 이스케이핑
- 해시
- 알고리즘
- Today
- Total
목록알고리즘 (33)
study record
기능개발 다양한 풀이 방법이 있는 문제지만 큐를 활용해보기로 했다. Math.ceil()이라는 메소드로 올림을 할 수 있다. 각 남은 날을 큐에 넣는다. 먼저 첫번째 날을 뽑아내고 큐가 비지 않을 때까지 다음꺼를 뽑고 비교해서 앞의 날이 더 크면 count를 ++한다. 뒤 값이 더 클 경우 그냥 count를 arraylist에 추가하고 cont =1로 초기화해준다. 앞 값을 현재 값으로 맞춰야 한다. 그렇게 정리된 arraylist값을 answer[]에 넣어준다. 다양한 방법이 있으니 다시 풀어 볼 것! import java.util.ArrayList; import java.util.LinkedList; import java.util.Queue; public class PerfomanceDevelop {..
더 맵게 PriorityQueue 를 사용하는 문제 heap은 정렬하지 않아도 peek()이나 poll()하면 가장 작은 값이 나온다. 힙은 우선순위 큐를 위해 만들어진 자료구조로, 부모노드 키 값이 자식 노드 키 값보다 항상 크거나 작다. import java.util.PriorityQueue; public class Spicer { public int solution(int[] scoville, int K) { int answer = 0; PriorityQueue heap = new PriorityQueue(); for (int i = 0; i K) { if(heap.siz..
완주하지못한 선수 HashMap을 이용한 문제 풀이 hash.put(key, value), hash.get(key)를 이용한 문제풀이를 진행했다. import java.util.HashMap; public class Hash { public static void main(String[] args) { String[] participant = {"marina", "josipa", "nikola", "vinko", "filipa"}; String[] completion = {"josipa", "filipa", "marina", "nikola"}; System.out.println(solution(participant, completion)); } public static String solution(Stri..
타겟넘버 문제 재귀를 활용한 BFS 문제 풀이 public class TargetNumber { public int solution(int[] numbers, int target) { int answer = 0; answer = bfs(numbers, target, numbers[0], 1) + bfs(numbers, target, -numbers[0], 1); return answer; } public int bfs(int[] numbers, int target, int sum, int i) { if(i == numbers.length) { if(sum == target) { return 1; } else { return 0; } } int result = 0; result += bfs(numbers,..