Blog/UB coding final list
OA2025-12-19

UB coding final list

UB coding

Problem

- [⚠️] Leetcode 5. Longest Palindromic Substring

- [✅] Leetcode 14. Longest Common Prefix

- [✅] Leetcode 53. Maximum Subarray DP

- [‼️] Leetcode 79. Word Search DFS

- [ ] Leetcode 127. Word Ladder

- [✅] Leetcode 146. LRU Cache double linked list + MAP

- [✅] Leetcode 200. Number of Islands

- [✅] Leetcode 204. Count Primes

- [✅] Leetcode 207. Course Schedule

- [‼️] Leetcode 212. Word Search II Trie + DFS

- [‼️] Leetcode 214. Shortest Palindrome manacher / KMP

- [‼️] Leetcode 230. Kth Smallest Element in a BST 中序遍历

- [✅] Leetcode 239. Sliding Window Maximum 单调队列

- [‼️] Leetcode 247. Strobogrammatic Number II

- [✅] Leetcode 253. Meeting Rooms II 时间排序+heap

- [‼️] Leetcode 269. Alien Dictionary

class Solution { public String alienOrder(String[] words) { List<Integer>[] graph = new ArrayList[26]; Arrays.setAll(graph, _ -> new ArrayList<>()); int n = words.length; int[] indegree = new int[26]; Set<Integer> met = new HashSet<>(); // ***** 提前把所有的字符加入集合,别在后边处理了, 也可以用boolean array来 for (String w : words) { for (char c : w.toCharArray()) { met.add(c - 'a'); } } for (int i = 0; i < n - 1; i++) { String cur = words[i]; String next = words[i + 1]; int minLen = Math.min(cur.length(), next.length()); boolean find = false; for (int j = 0; j < minLen; j++) { int from = cur.charAt(j) - 'a'; int to = next.charAt(j) - 'a'; if (cur.charAt(j) != next.charAt(j)) { find = true; indegree[to]++; graph[from].add(to); // ********* 终止 break; } } if (!find && cur.length() > next.length()) return ""; } Deque<Integer> queue = new ArrayDeque<>(); for (int i = 0; i < 26; i++) { if (indegree[i] == 0 && met.contains(i)) { queue.offerLast(i); } } StringBuilder sb = new StringBuilder(); while (!queue.isEmpty()) { int cur = queue.pollFirst(); sb.append((char) (cur + 'a')); for (int next : graph[cur]) { if (--indegree[next] == 0) { queue.offerLast(next); } } } if (sb.length() != met.size()) return ""; return sb.toString(); } }

- [‼️] Leetcode 305. Number of Islands II union find

- [✅] Leetcode 314. Binary Tree Vertical Order Traversal BFS or DFS + TreeMap

- [✅] Leetcode 347. Top K Frequent Elements PQ

- [✅] Leetcode 362. Design Hit Counter queue, follow up每人一个queue或者桶

- [‼️] Leetcode 365. Water and Jug Problem DFS状态判断环

- [‼️] Leetcode 380. Insert Delete GetRandom O(1)

- [‼️] Leetcode 381. Insert Delete GetRandom O(1) - Duplicates allowed 删除的跟队尾交换,删除队尾

- [‼️] Leetcode 384. Shuffle an Array

- [✅] Leetcode 399. Evaluate Division 跟汇率一个题目

- [‼️] Leetcode 410. Split Array Largest Sum 注意二分检查写法

- [✅] Leetcode 415. Add Strings

- [‼️] Leetcode 427. Construct Quad Tree 二维前缀和求面积

- [✅] Leetcode 549. Binary Tree Longest Consecutive Sequence II 二叉树左右返回

- [‼️] Leetcode 564. Find the Closest Palindrome 默写

- [✅] Leetcode 588. Design In-Memory File System Trie Tree

- [✅] Leetcode 638. Shopping Offers

- [⚠️ 复习] Leetcode 648. Replace Words Trie Tree

- [‼️] Leetcode 721. Accounts Merge 注意如何建图和保存

- [‼️] Leetcode 729. My Calendar I 前边的跟end,后边的跟start比

- [ ] Leetcode 749. Contain Virus

- [‼️] Leetcode 752. Open the Lock BFS visit在加queue时加

- [‼️] Leetcode 815. Bus Routes 对公交和route都要去重

- [‼️] Leetcode 934. Shortest Bridge DFS + BFS / 双向广搜

- [‼️] Leetcode 977. Squares of a Sorted Array 第K大,二分解法

- [✅] Leetcode 994. Rotting Oranges

- [✅] Leetcode 1101. The Earliest Moment When Everyone Become Friends

- [✅] Leetcode 1166. Design File System Trie Tree

- [‼️] Leetcode 1235. Maximum Profit in Job Scheduling DP 二分

- [⚠️] Leetcode 1244. Design A Leaderboard TreeMap store score cnt

- [‼️] Leetcode 1428. Leftmost Column with at Least a One

- [‼️] Leetcode 1429. First Unique Number LRU, LinkedHashSet()

- [✅] Leetcode 1438. Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit monotonic queue

- [‼️] Leetcode 1475. Final Prices With a Special Discount in a Shop 单调栈

- [‼️] Leetcode 2163. Minimum Difference in Sums After Removal of Elements two heap

- [‼️] Leetcode 2258. Escape the Spreading Fire BFS FireTime, BFS human

- [‼️] Leetcode 2402. Meeting Rooms III 用两个heap存free和busy

- [ ] Leetcode 2468. Split Message Based on Limit

- [‼️] Leetcode 2571. Minimum Operations to Reduce an Integer to 0 greedy

- [ ] Leetcode 2791. Count Paths That Can Form a Palindrome in a Tree

- [ ] Leetcode 2858. Minimum Edge Reversals So Every Node Is Reachable

- [✅] Design an in-memory database to handle transactions

- [ ] Package Installation Order