일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- 109. Convert Sorted List to Binary Search Tree
- Decorator
- Python
- Regular Expression
- Python Implementation
- t1
- DWG
- 프로그래머스
- Python Code
- kaggle
- shiba
- concurrency
- Substring with Concatenation of All Words
- iterator
- 파이썬
- 컴퓨터의 구조
- Protocol
- Class
- 밴픽
- 315. Count of Smaller Numbers After Self
- Generator
- 715. Range Module
- 운영체제
- 시바견
- attribute
- LeetCode
- 43. Multiply Strings
- Convert Sorted List to Binary Search Tree
- data science
- 30. Substring with Concatenation of All Words
- Today
- Total
목록Computer Science/Java (19)
Scribbling
https://leetcode.com/problems/least-number-of-unique-integers-after-k-removals/?envType=daily-question&envId=2024-02-16 class Solution { public int findLeastNumOfUniqueInts(int[] arr, int k) { Map counter = new HashMap(); for (int num : arr) { counter.merge(num, 1, Integer::sum); } List list = new ArrayList(); for (Integer key : counter.keySet()) { Integer val = counter.get(key); List tmp = new ..
https://leetcode.com/problems/find-servers-that-handled-most-number-of-requests/description/ class Solution { public List busiestServers(int k, int[] arrival, int[] load) { int[] counter = new int[k]; TreeSet servers = new TreeSet(); for (int i = 0; i < k; i++) { servers.add(i); } // [endTime, serverId] Queue schedules = new PriorityQueue(new Comparator() { @Override public int compare(int[] o1,..
class Solution { public int eraseOverlapIntervals(int[][] intervals) { if (intervals.length == 0) return 0; Arrays.sort(intervals, new Comparator(){ @Override public int compare(int[] o1, int[] o2) { return o1[1]-o2[1]; } }); int cnt = 1; int end = intervals[0][1]; for (int i=1; i= end) { cnt += 1; end = intervals[i][1]; } } return intervals.length - cnt; } }
class TrieNode { public boolean isWord = false; public TrieNode[] children = new TrieNode[26]; } class Trie { public TrieNode root; public Trie() { root = new TrieNode(); } public void insert(String word) { TrieNode cur = root; for (int i=0; i
LeetCode: 208. Implement Trie (Prefix Tree) class TrieNode { public boolean isWord = false; public TrieNode[] children = new TrieNode[26]; } class Trie { public TrieNode root; public Trie() { root = new TrieNode(); } public void insert(String word) { TrieNode cur = root; for (int i=0; i
Java STL provides ArrayDeque, LinkedList, and PriorityQueue. - LinkedList maintains the input order. - ArrayDeque maintains the input order as well. However, ArrayDeque is more efficient in terms of memory than LinkedList. LinkedList, on the other hand, is efficient when we need to remove elements frequently. - PriorityQueue maintains the natural order of data. For BFS, consider using ArrayDeque..
/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode() {} * ListNode(int val) { this.val = val; } * ListNode(int val, ListNode next) { this.val = val; this.next = next; } * } */ class Solution { public ListNode mergeKLists(ListNode[] lists) { if (lists == null || lists.length == 0) { return null; } PriorityQueue pq = new PriorityQueue( lists.l..
class Solution { public boolean isValid(String s) { Stack stack = new Stack(); for (var c: s.toCharArray()) { if (c == '{' || c == '[' || c == '(') { stack.add(c); } else { if (stack.empty()) return false; Character popped = stack.pop(); if (c == '}') { if (popped != '{') return false; } else if (c == ']') { if (popped != '[') return false; } else if (c == ')') { if (popped != '(') return false;..
class Solution { public String minWindow(String s, String t) { String ret = null; Set charSet = t.chars().mapToObj(c -> (char) c) .collect(Collectors.toSet()); List indexList = new ArrayList(); Map need = new HashMap(); for (int i=0; i
class Solution { public boolean isPalindrome(String s) { StringBuilder sb = new StringBuilder(); s.chars().filter(c -> Character.isLetterOrDigit(c)) .mapToObj(c -> Character.toLowerCase((char) c)) .forEach(sb::append); return sb.toString().equals(sb.reverse().toString()); } }