该书包含了LeetCode Online Judge(http://leetcode.com/onlinejudge)所有题目的答案。
该书假定读者已经学过《数据结构》《算法》这两门课,熟练掌握C++或Java.
《数据结构》严蔚敏等著,清华大学出版社
《Algorithms》,Robert Sedgewick,Addison-Weslev Professional.
该书代码开源,github地址:https://github.com/soulmachine/leetcode
???用char的值作为数组小标(例如,统计字符串中每个字符出现的次数),char可能为负数?
(a).有人考虑,可以先强制转型为unsigned int再用作下标,这任然是错滴?
(b)正确的做法:先强制为unsigned char,再用做小标。
使用reserve来避免不必要的重新分配?
双指针(题号:167):https://leetcode.com/problems/two-sum-ii-input-array-is-sorted/description/
排序:
快速选择、堆排序(题号:215):https://leetcode.com/problems/kth-largest-element-in-an-array/description/
桶排序(题号:347):https://leetcode.com/problems/top-k-frequent-elements/description/
荷兰国旗问题(题号:75):https://leetcode.com/problems/sort-colors/description/
贪心(题号:455):https://leetcode.com/problems/assign-cookies/description/
链接:https://pan.baidu.com/s/1QW2l4qx3tlYNINEKLyv4VA
提取码:6tod
链接:https://pan.baidu.com/s/19qAtmWbc1sXUWFEFb4wH2g
提取码:wcx4
二分(题号:69):https://leetcode.com/problems/sqrtx/description/
分治(题号:241):https://leetcode.com/problems/different-ways-to-add-parentheses/description/
链表(题号:160):https://leetcode.com/problems/intersection-of-two-linked-lists/description/
哈希表(题号:1):https://leetcode.com/problems/two-sum/description/
字符串(题号:242):https://leetcode.com/problems/valid-anagram/description/
栈和队列(题号:232):https://leetcode.com/problems/implement-queue-using-stacks/description/
字符串(409):https://leetcode.com/problems/longest-palindrome/description/
数组和矩阵(378):https://leetcode.com/problems/kth-smallest-element-in-a-sorted-matrix/description/
位运算(260):https://leetcode.com/problems/single-number-iii/description/
数学
进制转换(504):https://leetcode.com/problems/base-7/description/
相遇问题(462):https://leetcode.com/problems/minimum-moves-to-equal-array-elements-ii/description/
多数投票问题(169):https://leetcode.com/problems/majority-element/description/
Leetcode算法题:
树:
递归(110):https://leetcode.com/problems/balanced-binary-tree/description/
层次遍历(513):https://leetcode.com/problems/find-bottom-left-tree-value/description/
前中后序遍历(144):https://leetcode.com/problems/binary-tree-preorder-traversal/description/
BST(230):https://leetcode.com/problems/kth-smallest-element-in-a-bst/description/
Trie(208):https://leetcode.com/problems/implement-trie-prefix-tree/description/
图:
二分图(785):https://leetcode.com/problems/is-graph-bipartite/description/
拓扑排序(207):https://leetcode.com/problems/course-schedule/description/
并查集(684):https://leetcode.com/problems/redundant-connection/description/
第三周LeetCode参考答案:
链接:https://pan.baidu.com/s/1kpEu2QAzRQgBOZKav8mGcA
提取码:x041
LeetCode算法题:
搜索:
BFS(279):https://leetcode.com/problems/perfect-squares/description/
DFS(695):https://leetcode.com/problems/max-area-of-island/description/
Backtracking(17):https://leetcode.com/problems/letter-combinations-of-a-phone-number/description/
动态规划:
斐波那契数列(70):https://leetcode.com/problems/climbing-stairs/description/
矩阵路径(64):https://leetcode.com/problems/minimum-path-sum/description/
数组区间(303):https://leetcode.com/problems/range-sum-query-immutable/description/
分割整数(343):https://leetcode.com/problems/integer-break/description/
最长递增子序列(300):https://leetcode.com/problems/longest-increasing-subsequence/description/
0-1 背包(416):https://leetcode.com/problems/partition-equal-subset-sum/description/
股票交易(309):https://leetcode.com/problems/best-time-to-buy-and-sell-stock-with-cooldown/description/
字符串编辑(583):https://leetcode.com/problems/delete-operation-for-two-strings/description/
第四周LeetCode刷题参考答案:
链接:https://pan.baidu.com/s/1BvLJbAWRxCHEejod-sf7iQ
提取码:q8uw
第五周LeetCode答案:
链接:https://pan.baidu.com/s/18t8TagTwy5R9kUO678ftqw
提取码:adpb