LeetCode总结【转】
转自:http://blog.csdn.net/lanxu_yy/article/details/17848219
版权声明:本文为博主原创文章,未经博主允许不得转载。
最近完成了www.leetcode.com的online judge中151道算法题目。除各个题目有特殊巧妙的解法以外,大部分题目都是经典的算法或者数据结构,因此做了如下小结,具体的解题思路可以搜索我的博客:LeetCode题解
| 题目 | 算法 | 数据结构 | 注意事项 |
| Clone Graph | BFS | 哈希表 | |
| Word Ladder II | BFS | 哈希表 | |
| Surrounded Regions | BFS | 矩阵 | |
| Word Ladder | BFS | N/A | |
| Binary Tree Level Order Traversal | BFS|前序遍历 | 队列 | |
| Binary Tree Level Order Traversal II | BFS|前序遍历 | 队列 | |
| Binary Tree Zigzag Level Order Traversal | BFS|前序遍历 | 队列 | 每一层顺序分别对待 |
| Implement strStr() | KMP算法 | N/A | |
| Copy List with Random Pointer | N/A | 哈希表 | |
| Remove Duplicates from Sorted Array | N/A | 哈希表 | |
| Remove Duplicates from Sorted Array II | N/A | 哈希表 | |
| Set Matrix Zeroes | N/A | 哈希表 | |
| Anagrams | N/A | 哈希表 | |
| First Missing Positive | N/A | 哈希表 | |
| Two Sum | N/A | 哈希表 | |
| Evaluate Reverse Polish Notation | N/A | 堆栈 | |
| Largest Rectangle in Histogram | N/A | 堆栈 | 记录重要位置 |
| Minimum Window Substring | N/A | 堆栈 | |
| Simplify Path | N/A | 堆栈 | |
| Longest Valid Parentheses | N/A | 堆栈 | |
| Valid Parentheses | N/A | 堆栈 | 词法分析 |
| Container With Most Water | N/A | 堆栈 | 记录重要位置 |
| Reverse Words in a String | N/A | 堆栈 | 翻转字符串 |
| Best Time to Buy and Sell Stock | N/A | 数组 | |
| Best Time to Buy and Sell Stock II | N/A | 数组 | |
| Best Time to Buy and Sell Stock III | N/A | 数组 | |
| Length of Last Word | N/A | 数组 | |
| Search Insert Position | N/A | 数组 | |
| Search for a Range | N/A | 数组 | |
| Spiral Matrix | N/A | 矩阵 | 简化为子问题 |
| Spiral Matrix II | N/A | 矩阵 | 简化为子问题 |
| LRU Cache | N/A | 链表 | |
| Reorder List | N/A | 链表 | 快慢指针&链表倒序 |
| Linked List Cycle | N/A | 链表 | 快慢指针 |
| Linked List Cycle II | N/A | 链表 | 快慢指针 |
| Reverse Linked List II | N/A | 链表 | |
| Partition List | N/A | 链表 | |
| Remove Duplicates from Sorted List | N/A | 链表 | |
| Remove Duplicates from Sorted List II | N/A | 链表 | |
| Merge Two Sorted Lists | N/A | 链表 | |
| Rotate List | N/A | 链表 | 快慢指针 |
| Reverse Nodes in k-Group | N/A | 链表 | |
| Swap Nodes in Pairs | N/A | 链表 | |
| Remove Nth Node From End of List | N/A | 链表 | 快慢指针 |
| Text Justification | N/A | 队列 | |
| Candy | N/A | N/A | 简化为子问题 |
| Valid Palindrome | N/A | N/A | 首尾指针 |
| Plus One | N/A | N/A | 模拟加法运算 |
| Valid Number | N/A | N/A | 词法分析 |
| Add Binary | N/A | N/A | 模拟加法运算 |
| Insert Interval | N/A | N/A | |
| Merge Intervals | N/A | N/A | |
| Multiply Strings | N/A | N/A | 模拟乘法运算 |
| Trapping Rain Water | N/A | N/A | |
| Valid Sudoku | N/A | N/A | |
| Roman to Integer | N/A | N/A | |
| Integer to Roman | N/A | N/A | |
| Palindrome Number | N/A | N/A | |
| Reverse Integer | N/A | N/A | |
| ZigZag Conversion | N/A | N/A | |
| Add Two Numbers | N/A | N/A | 模拟加法运算 |
| Median of Two Sorted Arrays | N/A | N/A | |
| String to Integer (atoi) | STL函数 | N/A | |
| Next Permutation | STL经典算法 | N/A | |
| Recover Binary Search Tree | 中序遍历 | 二叉树 | |
| 3Sum | 二分查找 | N/A | |
| 3Sum Closest | 二分查找 | N/A | |
| 4Sum | 二分查找 | N/A | |
| Single Number | 位运算 | N/A | |
| Single Number II | 位运算 | N/A | |
| Construct Binary Tree from Preorder and Inorder Traversal | 前序中序遍历 | N/A | |
| Binary Tree Preorder Traversal | 前序遍历 | 二叉树 | |
| Flatten Binary Tree to Linked List | 前序遍历 | 二叉树 | |
| Interleaving String | 动态规划 | 二叉树 | |
| Unique Binary Search Trees | 动态规划 | 二叉树 | |
| Word Break | 动态规划 | N/A | |
| Word Break II | 动态规划 | N/A | |
| Palindrome Partitioning | 动态规划 | N/A | |
| Palindrome Partitioning II | 动态规划 | N/A | |
| Triangle | 动态规划 | N/A | |
| Distinct Subsequences | 动态规划 | N/A | |
| Decode Ways | 动态规划 | N/A | |
| Scramble String | 动态规划 | N/A | |
| Maximal Rectangle | 动态规划 | N/A | |
| Edit Distance | 动态规划 | N/A | |
| Climbing Stairs | 动态规划 | N/A | |
| Minimum Path Sum | 动态规划 | N/A | |
| Unique Paths | 动态规划 | N/A | |
| Unique Paths II | 动态规划 | N/A | |
| Jump Game | 动态规划 | N/A | |
| Jump Game II | 动态规划 | N/A | |
| Maximum Subarray | 动态规划 | N/A | |
| Wildcard Matching | 动态规划 | N/A | |
| Substring with Concatenation of All Words | 动态规划 | N/A | |
| Sort List | 合并排序 | 链表 | 快慢指针 |
| Merge Sorted Array | 合并排序 | N/A | |
| Construct Binary Tree from Inorder and Postorder Traversal | 后序中序遍历 | N/A | |
| Binary Tree Postorder Traversal | 后续遍历 | 二叉树 | |
| Combinations | 回溯 | N/A | |
| Permutation Sequence | 回溯 | N/A | |
| N-Queens | 回溯 | N/A | |
| N-Queens II | 回溯 | N/A | |
| Permutations | 回溯 | N/A | |
| Permutations II | 回溯 | N/A | |
| Combination Sum | 回溯 | N/A | |
| Combination Sum II | 回溯 | N/A | |
| Sudoku Solver | 回溯 | N/A | |
| Longest Substring Without Repeating Characters | 回溯 | N/A | |
| Max Points on a Line | 循环遍历 | N/A | 排除相同的点 |
| Longest Common Prefix | 循环遍历 | N/A | |
| Longest Palindromic Substring | 循环遍历 | N/A | |
| Insertion Sort List | 插入排序 | 链表 | |
| Rotate Image | 矢量旋转与平移 | N/A | |
| Longest Consecutive Sequence | 类BFS | 哈希表 | |
| Search in Rotated Sorted Array | 类二分查找 | N/A | |
| Search in Rotated Sorted Array II | 类二分查找 | N/A | 特殊考虑相等数据 |
| Sqrt(x) | 类二分查找 | N/A | |
| Pow(x, n) | 类二进制 | N/A | |
| Divide Two Integers | 类二进制 | N/A | |
| Gas Station | 类合并排序 | N/A | |
| Merge k Sorted Lists | 类外排序 | N/A | |
| Sort Colors | 类快速排序 | N/A | |
| Remove Element | 类快速排序 | N/A | |
| Search a 2D Matrix | 类杨氏矩阵 | N/A | |
| Restore IP Addresses | 背包问题 | N/A | |
| Sum Root to Leaf Numbers | 递归 | 二叉树 | |
| Binary Tree Maximum Path Sum | 递归 | 二叉树 | |
| opulating Next Right Pointers in Each Node | 递归 | 二叉树 | |
| Populating Next Right Pointers in Each Node II | 递归 | 二叉树 | |
| Path Sum | 递归 | 二叉树 | |
| Path Sum II | 递归 | 二叉树 | |
| Maximum Depth of Binary Tree | 递归 | 二叉树 | |
| Minimum Depth of Binary Tree | 递归 | 二叉树 | |
| Balanced Binary Tree | 递归 | 二叉树 | |
| Symmetric Tree | 递归 | 二叉树 | |
| Same Tree | 递归 | 二叉树 | |
| Validate Binary Search Tree | 递归 | 二叉树 | |
| Unique Binary Search Trees II | 递归 | 二叉树 | |
| Binary Tree Inorder Traversal | 递归 | 二叉树 | |
| Pascal's Triangle | 递归 | N/A | |
| Pascal's Triangle II | 递归 | N/A | |
| Convert Sorted List to Binary Search Tree | 递归 | N/A | 快慢指针&反中序遍历 |
| Convert Sorted Array to Binary Search Tree | 递归 | N/A | 反中序遍历 |
| Subsets | 递归 | N/A | |
| Subsets II | 递归 | N/A | |
| Gray Code | 递归 | N/A | |
| Word Search | 递归 | N/A | |
| Count and Say | 递归 | N/A | |
| Generate Parentheses | 递归 | N/A | |
| Letter Combinations of a Phone Number | 递归 | N/A | |
| Regular Expression Matching | 递归 | N/A |
LeetCode总结【转】的更多相关文章
- 我为什么要写LeetCode的博客?
# 增强学习成果 有一个研究成果,在学习中传授他人知识和讨论是最高效的做法,而看书则是最低效的做法(具体研究成果没找到地址).我写LeetCode博客主要目的是增强学习成果.当然,我也想出名,然而不知 ...
- LeetCode All in One 题目讲解汇总(持续更新中...)
终于将LeetCode的免费题刷完了,真是漫长的第一遍啊,估计很多题都忘的差不多了,这次开个题目汇总贴,并附上每道题目的解题连接,方便之后查阅吧~ 477 Total Hamming Distance ...
- [LeetCode] Longest Substring with At Least K Repeating Characters 至少有K个重复字符的最长子字符串
Find the length of the longest substring T of a given string (consists of lowercase letters only) su ...
- Leetcode 笔记 113 - Path Sum II
题目链接:Path Sum II | LeetCode OJ Given a binary tree and a sum, find all root-to-leaf paths where each ...
- Leetcode 笔记 112 - Path Sum
题目链接:Path Sum | LeetCode OJ Given a binary tree and a sum, determine if the tree has a root-to-leaf ...
- Leetcode 笔记 110 - Balanced Binary Tree
题目链接:Balanced Binary Tree | LeetCode OJ Given a binary tree, determine if it is height-balanced. For ...
- Leetcode 笔记 100 - Same Tree
题目链接:Same Tree | LeetCode OJ Given two binary trees, write a function to check if they are equal or ...
- Leetcode 笔记 99 - Recover Binary Search Tree
题目链接:Recover Binary Search Tree | LeetCode OJ Two elements of a binary search tree (BST) are swapped ...
- Leetcode 笔记 98 - Validate Binary Search Tree
题目链接:Validate Binary Search Tree | LeetCode OJ Given a binary tree, determine if it is a valid binar ...
- Leetcode 笔记 101 - Symmetric Tree
题目链接:Symmetric Tree | LeetCode OJ Given a binary tree, check whether it is a mirror of itself (ie, s ...
随机推荐
- 使用natapp本地映射外网服务
官网:https://natapp.cn/ 软件很好用,这对于前端工程师来说,有了这个工具就很爽了,当你的领导或者不在你公司内网范围内的人,想要看你的页面效果,就很简单了. 详细的不用更多介绍,直接去 ...
- 使用shell脚本添加用户
该文演示如何使用shell脚本完成添加用户,首先进行一个判断,如果用户存在,提示该用户已经存在,否则进行添加新的用户. 示例代码如下: #!/bin/bash grep_user() { R=`gre ...
- day 44 前端HTML
前端HTML HTML介绍 Web服务本质 import socket sk = socket.socket() sk.bind(("127.0.0.1", 8080)) sk ...
- [译]The Python Tutorial#11. Brief Tour of the Standard Library — Part II
[译]The Python Tutorial#Brief Tour of the Standard Library - Part II 第二部分介绍更多满足专业编程需求的高级模块,这些模块在小型脚本中 ...
- python2与python3的区别,以及注释、变量、常量与编码发展
python2与python3的区别 宏观上: python2:源码不统一,混乱,重复代码太多. python3:源码统一标准,能去除重复代码. 编码上: python2:默认编码方式为ASCII码. ...
- 用 Tensorflow 建立 CNN
稍稍乱入的CNN,本文依然是学习周莫烦视频的笔记. 还有 google 在 udacity 上的 CNN 教程. CNN(Convolutional Neural Networks) 卷积神经网络简单 ...
- linux下编译运行TIGL Viewer步骤
linux下编译运行TIGL Viewer步骤(仅为了正确编译安装的话直接跳到步骤3) 1. linux发行版选择:由于linux发行版众多,不同版本包含的库版本可能存在差别,因此需要选择正确的版本. ...
- apizza导出为html后,从中提取api_name/api_path/api_method,保存到本地,方便根据接口名称得到接口路径与请求方法
import re import os def open_file(file='c:/newcrm.html'): f=open(file,'r',encoding='utf-8') return f ...
- Python+Selenium练习篇之16-自定义浏览器窗口大小
本文来学习下如何通过Selenium方法,设置符合不同测试场景浏览器窗口大小.例如,你有一台机器,最大支持1366*768,你完全可以利用这个机器测试不同分辨率下的场景. 相关测试脚本代码如下: # ...
- Leetcode 542.01矩阵
01矩阵 给定一个由 0 和 1 组成的矩阵,找出每个元素到最近的 0 的距离. 两个相邻元素间的距离为 1 . 示例 1: 输入: 0 0 0 0 1 0 0 0 0 输出: 0 0 0 0 1 0 ...