摘要:一、labuladong动态规划模板思路 wiki:https://labuladong.gitee.io/algo/di-ling-zh-bfe1b/dong-tai-g-1e688/ 题目: 动态规划模板思路: 二、我自己如何理解【状态】【选择】 以714题目《最佳时机去买卖股票+手续费》为例子
阅读全文
摘要:回溯算法 动态规划 通解通法 动态规划问题的一般形式就是求最值 判断算法问题是否具备「最优子结构」,是否能够通过子问题的最值得到原问题的最值 明确 base case -> 明确「状态」-> 明确「选择」 -> 定义 dp 数组/函数的含义 「状态」就是指,f(n) 把参数 n 想做一个状态,这个状
阅读全文
摘要:https://medium.com/@hch.hkcontact/goldman-sachs-top-50-leetcode-questions-q7-high-five-a933247c219a Coderpad describe how to implement HashMap Impleme
阅读全文
摘要:模板 数组里找超过1/2,1/3个数的数字 通解通法:摩尔投票法 一个数组,超过1/2的数字,至多有1个;超过1/3的数字,至多有2个... 超过1/2: 169. 多数元素 超过1/3:229. 求众数 II 疑问:最后留下的一定是超过1/2,或者1/3么? https://leetcode-cn
阅读全文
摘要:List<List<Integer>> kSum_Trim(int[] a, int target, int k) { List<List<Integer>> result = new ArrayList<>(); if (a == null || a.length < k || k < 2) return result; Arrays.sort(a); kSum_Trim(a, target,
阅读全文
摘要:题目Given an array of n integers where n > 1, nums, return an array output such that output[i] is equal to the product of all the elements of nums excep
阅读全文
摘要:110. Balanced Binary Tree Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary tree is defined as: a bi
阅读全文
摘要:URL: https://leetcode.com/problems/house-robber-ii/ You are a professional robber planning to rob houses along a street. Each house has a certain amou
阅读全文
摘要:URL : https://leetcode.com/problems/house-robber/ You are a professional robber planning to rob houses along a street. Each house has a certain amount
阅读全文
摘要:url: https://leetcode.com/problems/rotate-array/ Given an array, rotate the array to the right by k steps, where k is non-negative. Example 1: Example
阅读全文