LeetCode/LintCode 部分需要熟记的问题列表 (临时整理)

Binary Search

  1. Binary Search 模板 //背
  2. Binary Search in Rotated Array
  3. Find K Smallest Element in BST
    Follow up: What if the BST nodes are updated frequently, or the FindKthSmallestElem() is called frequently. We can use QuickSelect() and preprocessint to record # of subtree nodes of each BST node ???

Binary Tree

  1. Binary tree in-order traversal (non-recursion) //重点背
    pre-order and post-order traversal (non-recursion) 最好也背
  2. Binary search tree iterator //背
  3. Lowest Common Ancestor

Word 4大重点题: //每题至少5遍

  1. Word Pattern I, II
  2. Word Search I, II
  3. Word Ladder I, II
  4. Word Break I, II //30分钟AC

Regular Expression Matching //至少5遍,30分钟AC
Wildcard Matching //DP

String Permutation II

Merge Two Sorted Arrays
Merge K Sorted Array //3种方法
Merge Two Sorted Lists
Merge K Sorted List //3种方法
a) Priority Queue
b) Merge (from bottom to top)
c) Merge Sort (from top to bottom)

Merge Two Sorted Interval Lists
Merge K Sorted Interval Lists //use cache? 3种方法

Maximum Subarray //use Prefix Sum
Best time to Buy and Sell Stock //use Prefix Sum, similar to Maximum Subarray

Find the Kth Largest Number in an Unsorted Array //Quick Select
Find the Median of K Sorted Arrays //use Binary Search !!!
//cannot use the solution of find the Kth largest number of N Sorted Arrays

Binary Index Tree
update(), getPrefixSum, SetRangeSum() //背

LRU Cache //高频中的高频
a) Doubly Linked List + Hash
b) Single Linked List + Hash

数据流问题

  1. Find Unique Character in a String
    //不能做两次遍历
  2. Insert(), Delete() and GetRandom()

K Closest Points //3 solutions
a) Simple Sort O(nlogn)
b) Quick Select O(n)
c) Priority Queue O(nlogn)
- Priority Queue Improved Version

Sorting
Quick Sort //极其重要 背 记得是left<=right, 等于情况两边都要去
Merge Sort
Bubble Sort //掌握
RainBow Sort
Counting Sort

个人总结:
binary search用于已经排好序的场合,比如Median of two Sorted Arrays

quick select法通常用来在未排序的数组中寻找第k小/第k大的元素。

对于诸如merge K sorted arrays/interval lists之类的问题, 可用priority_queue+tuple。

一些容易混淆的题目:
1)
Longest Common Substring (DP, 不用考虑DP[i-1][j]和DP[i][j-1])
Longest Common Subsequence ((DP, 需要考虑DP[i-1][j]和DP[i][j-1]))
Longest Increasing Subsequence (用DP或二分)
Longest Continuous Increasing Subsequence (用一个循环遍历即可)
Longest Common Prefix (用HashMap或Trie)

LintCode 402 Continuous Subarray Sum 这题不要跟LIS混淆,并且这题有2个变种
LintCode 558 求固定长度的连续序列的最大和
LintCode 403 Continuous Subarray Sum II (LintCode 402 +循环数组)

左右侧最近更大数问题(单调递增栈)
直方图求最大矩形 (单调递增栈)
二维蓄水池最大蓄水量(反向双指针或先算最大高度然后从左右两边分头算)

一些跟数学相关的问题

  1. 素数相关问题
  2. 随机数相关问题
  3. 几何相关问题
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值