목록분류 전체보기 (166)
공부기록
${CONSOLE_LOG_PATTERN} ${CONSOLE_LOG_CHARSET} 로거들은 자신에게 요청하는 코드의 레벨이 맞을 때 로그를 뱉는다. 이 글을 쓰는 이유는 root의 레벨에 따라 logger가 필터링 되는줄 알아서 쓴다.... 내가 경험한 문제는 jdbc.sqltiming을 root가 debug 레벨일 때에 출력하고 싶었던 것이었다. 하지만 애초에 내가 logback의 요청 수용 방식, root 와 logger의 상속관계가 무엇인지 몰라서 벌어진 일이었다. 일단 logback의 logger들은 요청을 받는다. ALogger.debug() 뭐 이런 식으로 요청을 받는데 이 때 ALogger의 레벨이 debug 이하여야 수용할 수 있다는 것이다. ALogger의 레벨이 만약 info 이상이라면..
문제 https://leetcode.com/problems/search-a-2d-matrix/ 코드 import java.util.*; class Solution { public boolean searchMatrix(int[][] matrix, int target) { int M = matrix.length; int N = matrix[0].length; int start=0; int end=M-1; int mid = 0; while(start = target){ end = mid; }else{ start = mid+1; } } int curRow = end; start = 0; end = N-1; while(sta..
문제 https://leetcode.com/problems/group-anagrams/ 코드 import java.util.*; class Solution { public List groupAnagrams(String[] strs) { Map m = new HashMap(); List res = new ArrayList(); for(String str : strs){ char[] tmp = str.toCharArray(); Arrays.sort(tmp); String k = new String(tmp); if(m.get(k) == null) m.put(k, new ArrayList()); m.get(k).add(str); } for(String key : m.keySet()) res.add(m.get(k..
문제 https://leetcode.com/problems/top-k-frequent-elements/ 코드 import java.util.*; class Solution { class Node implements Comparable{ int num; int count; public Node(int num, int count){ this.num = num; this.count = count; } @Override public int compareTo(Node n){ if(this.count < n.count) return 1; else if(this.count == n.count) return 0; return -1; } } public int[] topKFrequent(int[] nums, int k)..
문제 https://leetcode.com/problems/largest-number/ 코드 import java.util.*; class Solution { public String largestNumber(int[] nums) { List list = new ArrayList(); if(nums.length == 1) return String.valueOf(nums[0]); list.add(String.valueOf(nums[0])); for(int i=1; i
문제 https://leetcode.com/problems/shuffle-an-array/ 코드 import java.util.*; class Solution { private List prevRes; private List res; private List resIdx; private int[] nums; private boolean visit[]; private boolean isSet = false; private boolean isEnd = false; public Solution(int[] nums) { this.nums = nums; this.res = new ArrayList(); this.resIdx = new ArrayList(); this.visit = new boolean[nums.le..
문제 https://leetcode.com/problems/course-schedule-ii/ 코드 import java.util.*; class Solution { public int[] findOrder(int numCourses, int[][] prerequisites) { List g[] = new List[numCourses]; int dp[] = new int[numCourses]; boolean visit[] = new boolean[numCourses]; List res = new ArrayList(); Queue q = new LinkedList(); for(int i=0; i
문제 https://leetcode.com/problems/search-a-2d-matrix-ii/ 코드 import java.util.*; class Solution { public boolean searchMatrix(int[][] matrix, int target) { int N = matrix.length; int M = matrix[0].length; int curRow = 0; int curCol = M-1; while(curCol >= 0 && curRow target) curCol--; else curRow++; } return false; } } 피드백 일단 예전에 풀었던 거지만 다시 못풀었다. (전에도 다시 못풀었음) 모범 답안은 오른쪽 끝에서 시작해서 현재 수가 target 보다 크면..