일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- 리소스모니터링
- Properties
- dfs
- 힙덤프
- JPA
- Union-find
- javascript
- date
- 스프링부트
- html
- map
- List
- deque
- CSS
- alter
- 스택
- 큐
- Java
- scanner
- BFS
- union_find
- set
- string
- spring boot
- Calendar
- NIO
- sql
- priority_queue
- GC로그수집
- math
- Today
- Total
목록분류 전체보기 (309)
매일 조금씩
![](http://i1.daumcdn.net/thumb/C150x150.fwebp.q85/?fname=https://blog.kakaocdn.net/dn/kITLe/btsJ288p0CE/HHDBp8iMKDl18BDAkR9jJk/img.png)
기술 스택 : Kafka, Spring, JPA, QueryDSL, Mysql, NodeJS, AWS EC2 jpa buddy조회 속도를 위해 fk를 반드시 필요한 곳에만 최소화함.
![](http://i1.daumcdn.net/thumb/C150x150.fwebp.q85/?fname=https://blog.kakaocdn.net/dn/4r36o/btsJ4nXobZK/gRsPqKL90amSHqfKoHfzg1/img.png)
BFS의 대표적인 문제유형 중 하나인, 감염 문제이다.메모리 효율을 위해 visited 객체를 따로 생성해서 쓰지않고 방문한 곳은 주어진 그래프에서 값을 업데이트 하는 방식으로 했다. 이미 썩은 오렌지가 몇개 있는 상태에서 시작하므로 큐를 첨에 시간 초깃값을 -1로 설정해서 큐를 돌게 한다. class Solution { public int orangesRotting(int[][] grid) { int rows = grid.length; int cols = grid[0].length; int fresh = 0; Queue queue = new LinkedList(); for(int row = 0; row = rows || col = co..
![](http://i1.daumcdn.net/thumb/C150x150.fwebp.q85/?fname=https://blog.kakaocdn.net/dn/BJMFm/btsJ3IH9NHa/E3kB7lkJoZEoAfyZhCKJp0/img.png)
BFS의 대표적인 유형중 하나인, 빠른 탈출 문제이다.메모리 효율을 위해 visited 객체를 따로 생성해서 쓰지않고 방문한 곳은 주어진 그래프에서 값을 업데이트 하는 방식으로 했다. class Solution { public int nearestExit(char[][] maze, int[] entrance) { int rows = maze.length; int cols = maze[0].length; Queue queue = new LinkedList(); queue.offer(entrance); // 이렇게 지나온 곳을 장애물로 표시하고 지나가면 // visited 관련 객체를 따로 관리 하지 않아도돼서 메모리를 아낄수..
![](http://i1.daumcdn.net/thumb/C150x150.fwebp.q85/?fname=https://blog.kakaocdn.net/dn/NZeNo/btsJ3oW8kdm/plhDMtuN7Z2zed19S176xk/img.png)
이 문제도 방향성이 있는 그래프 문제와 다름이 없다. 노드간 방향성이 있는 그래프로 그려보면..각 간선을 연결하면 곱이라는 연산으로 정의 내려질수 있고,기존 방향과 반대 방향의 가중치는 진입 차수 배열에 1/(가중치)로 저장되면 된다.a/b = 2 이고, b/c = 2일때, a/c == (a/b) * (b/c) 이기 때문.. class Solution { public double[] calcEquation(List> equations, double[] values, List> queries) { double[] finalAns = new double[queries.size()]; // 노드와 그에 연결된 간선들을 저장 HashMap> map = new Hash..
![](http://i1.daumcdn.net/thumb/C150x150.fwebp.q85/?fname=https://blog.kakaocdn.net/dn/df92i4/btsJ1IaVgiv/aGckFyA0UjAXg9CkyuAPi0/img.png)
방향성이 있는 그래프에서 진입차수 배열에 주어진 방향의 반대방향도 넣어두는 것이 포인트이다.다만 이 반대방향이 주어진 방향을 뒤집은 방향이라는 것을 알게 하기 위해 음수로 저장했다. class Solution { public int minReorder(int n, int[][] connections) { List> al = new ArrayList(); boolean[] visited = new boolean[n]; for(int i = 0; i ()); } // 한 방향에 대해서 양방향으로 저장함. // 이때, 시작점에서 나가는건 양수, 반대는 음수로 저장. // => 여기선 시작점인 0 부터 차차 탐색하기 때..
![](http://i1.daumcdn.net/thumb/C150x150.fwebp.q85/?fname=https://blog.kakaocdn.net/dn/nAXyL/btsJ3KFAlVI/ZKVDrwuBvnBmRiz3NKH1KK/img.png)
이문제는 dfs, bfs 로 풀수도 있지만 HashSet 객체를 활용해서 문제를 해결했다. class Solution { public int longestConsecutive(int[] nums) { Set numSet = new HashSet(); for (int num : nums) { numSet.add(num); } int longest = 0; for (int num : nums) { if (!numSet.contains(num - 1)) { int length = 1; // num이 연속된 수의 시작일 떄 ..