Leetcode Round 3 记录
[完全没有思路]
Array
1. Remove Duplicates from Sorted Array II
Tree
1. Symmetric Tree (No Recursion Solution: two queues)
2. Unique Binary Search Trees II
HashTable
1. Sudoku Solver
Math
1. Divide Two Integers [实现除法,不能用乘除和取余符号; 位运算,二分]
2. Different Ways to Add Parentheses [分治法]
3. Number of Digit One [分情况枚举]
4. Excel Sheet Column Title [对Z分情况]
String
1. Decode Ways []
2. Shortest Palindrome []
3. Regular Expression Matching [特殊情况为第二个字符为"*"]
4. Distinct Subsuquences [dp]
DP
1. Gas Station []
Backtracking
1. Permutations II
[找不到正确的解法]
Array
1. Largest Retangle in Histogram
Tree
1. Binary Tree Maximum Path [递归helper函数]
String
1. Compare Version Numbers [设计比较方法是难点,test case]
2. Interleaving String [dp]
DataStructure
1. LRU [双向链表+节点操作]
DFS & BFS
1. Surrounded Regions [dfs栈溢出,需要用bfs,题目的精髓为dfs转bfs]
[有正确的解法但是复杂度不符合要求]
Array
1. Minimum Size Subarray Sum [Two Pointers]
2. Jump Game II [Greedy]
HashTable
1. Count Primes [素数生成法]
2. Repeated DNA Seq [HashSet不存字符串,存编码值]
String
1. Multiply Strings [有更加简洁的方法]
Math
1. Factorial Trailing Zeros [log复杂度]
[提交多次才通过]
Array
1. Set Matrix zeros [常数空间复杂度]
2. Spiral Matrix [边界cyc]
3. Kth Largest Element in an Array [partition函数应该使得数组保持从大到小的顺序]
String
1. Minimum Window Substring [two pointers, 移动的条件,两张HashMap]
2. Count and Say [设计字符串变化规则]
3. Atoi [bad case: +-2, +00012abc]
4. Multiply Strings [注意"9133"*"0", 结果为"0000"]
5. Longest Valid Parentheses ["((()))())"]
6. Shortest Palindrome [中心拓展法,先判断单点中心的拓展]
Tree
1. Populating Next Right Pointers II [两次贪心]
Math
1. Pow(x, n) [注意n为负数的边界条件]
2. Palindrome Number [while(x / base >= 10), x = (x % 10) / 10].