全排列
针对1 - n 的数字全排列成字符串
1 | //全排列 |
排序算法
1 | //插入排序 |
LeetCode146. LRU缓存机制
1 | //自己实现 |
###
动态规划
01背包
1 | //01背包 |
LeetCode416. 分割等和子集
1 | //简单易懂的递归 |
LeetCode322. 零钱兑换
1 | public int coinChange(int[] coins, int amount) { |
LeetCode377. 组合总和 Ⅳ
1 | public int combinationSum4(int[] nums, int target) { |
LeetCode 474. 一和零
代码超级简洁,就是不一定能迅速想得出来。
1 | public int findMaxForm(String[] strs, int m, int n) { |
LeetCode139. 单词拆分
1 | //递归法,但是超时,也许思路有用? |
Leetcode494. 目标和
这个跟01背包类似,却不一样!
因为目标和可能来自比它大的,也可能来自比它小的
因此是通过某个元素去得到它能到达的值,而不是通过能到达它相邻某个元素的情况数得到该元素的值
也就是通过原因推结果,而不是结果推原因!
而且考虑到动态过程中的值未知性,不能通过数组存储,直接通过HashMap存储!
1 | public int findTargetSumWays(int[] nums, int S) { |
LeetCode84. 柱状图中最大的矩形
单调栈问题
https://zhuanlan.zhihu.com/p/26465701
1 | public int largestRectangleArea(int[] heights) { |