04 2020 档案

dp背包 面试题 08.11. 硬币
摘要:https://leetcode-cn.com/problems/coin-lcci/ 硬币。给定数量不限的硬币,币值为25分、10分、5分和1分,编写代码计算n分有几种表示法。(结果可能会很大,你需要将结果模上1000000007) 示例1: 输入: n = 5 输出:2 解释: 有两种方式可以凑 阅读全文

posted @ 2020-04-29 20:46 wsw_seu 阅读(157) 评论(0) 推荐(0) 编辑

1、线性DP 213. 打家劫舍 II
摘要:https://leetcode-cn.com/problems/house-robber-ii/ //rob 0, not rob n-1 || not rob 0,not rob n-1 ==>rob(0,nums.length-2,nums) //not rob 0,rob n-1 || no 阅读全文

posted @ 2020-04-26 10:21 wsw_seu 阅读(133) 评论(0) 推荐(0) 编辑

4. 树形DP
摘要:337. 打家劫舍 III https://leetcode-cn.com/problems/house-robber-iii/ /** * Definition for a binary tree node. * type TreeNode struct { * Val int * Left *T 阅读全文

posted @ 2020-04-26 10:09 wsw_seu 阅读(96) 评论(0) 推荐(0) 编辑

1248. 统计「优美子数组」
摘要:https://leetcode-cn.com/problems/count-number-of-nice-subarrays/ func numberOfSubarrays(nums []int, k int) int { //滑动窗口法:left 每次滑动到下一个奇数处,并记下滑动的距离;rig 阅读全文

posted @ 2020-04-23 22:53 wsw_seu 阅读(187) 评论(0) 推荐(0) 编辑

1、线性DP 198. 打家劫舍
摘要:198. 打家劫舍 https://leetcode-cn.com/problems/house-robber/ //dp动态规划,dp[i] 状态表示0-i家的盗的得最大值。那么dp[i] = (dp[i-1],dp[i-2]+nums[i]) //第i家不偷,或者第i家偷,就这两种子问题。 fu 阅读全文

posted @ 2020-04-23 22:50 wsw_seu 阅读(131) 评论(0) 推荐(0) 编辑

1、线性DP 354. 俄罗斯套娃信封问题
摘要:354. 俄罗斯套娃信封问题 https://leetcode-cn.com/problems/russian-doll-envelopes/ 算法分析 首先我们从两种情况来讨论这个问题: w无重复值(即信封的宽度每个信封都不一样) w可以重复(即信封的宽度存在一样的,题目就是这种情况) 针对情况I 阅读全文

posted @ 2020-04-22 18:59 wsw_seu 阅读(220) 评论(0) 推荐(0) 编辑

127. 单词接龙
摘要:127. 单词接龙 https://leetcode-cn.com/problems/word-ladder/ func ladderLength(beginWord string, endWord string, wordList []string) int { i := 0 n := len(w 阅读全文

posted @ 2020-04-21 20:56 wsw_seu 阅读(167) 评论(0) 推荐(0) 编辑

1. 线性DP 887. 鸡蛋掉落 (DP+二分)
摘要:887. 鸡蛋掉落 (DP+二分) https://leetcode-cn.com/problems/super-egg-drop/ /*首先分析1个蛋,1个蛋的话,最坏情况需要N次,每次只能从0 1 2 。。。开始如果蛋的个数随便用,或者说2的k次方大于等于N楼层高度,则可以利用二分。如果蛋的个数 阅读全文

posted @ 2020-04-21 18:01 wsw_seu 阅读(235) 评论(0) 推荐(0) 编辑

200. 岛屿数量
摘要:200. 岛屿数量 https://leetcode-cn.com/problems/number-of-islands/ func numIslands(grid [][]byte) int { n := len(grid) if n == 0{ return 0 } //初始全部未访问过 fal 阅读全文

posted @ 2020-04-21 15:57 wsw_seu 阅读(134) 评论(0) 推荐(0) 编辑

1. 线性DP 152. 乘积最大子数组
摘要:152. 乘积最大子数组 https://leetcode-cn.com/problems/maximum-product-subarray/ func maxProduct(nums []int) int { preMax,preMin,curMax,curMin,res := nums[0],n 阅读全文

posted @ 2020-04-20 16:50 wsw_seu 阅读(138) 评论(0) 推荐(0) 编辑

1. 线性DP 53. 最大子序和.
摘要:53. 最大子序和. https://leetcode-cn.com/problems/maximum-subarray/ func maxSubArray(nums []int) int { dp := make([]int,len(nums)) dp[0] = nums[0] for i:=1; 阅读全文

posted @ 2020-04-20 16:17 wsw_seu 阅读(147) 评论(0) 推荐(0) 编辑

1. 线性DP 120. 三角形最小路径和
摘要:经典问题: 120. 三角形最小路径和 https://leetcode-cn.com/problems/triangle/ func minimumTotal(triangle [][]int) int { n := len(triangle) dp := make([][]int,n) for 阅读全文

posted @ 2020-04-19 23:18 wsw_seu 阅读(112) 评论(0) 推荐(0) 编辑

1. 线性DP 1143. 最长公共子序列
摘要:最经典双串: 1143. 最长公共子序列 (LCS) https://leetcode-cn.com/problems/longest-common-subsequence/submissions/ func longestCommonSubsequence(text1 string, text2 阅读全文

posted @ 2020-04-19 15:53 wsw_seu 阅读(151) 评论(0) 推荐(0) 编辑

1. 线性DP 300. 最长上升子序列 (LIS)
摘要:最经典单串: 300. 最长上升子序列 (LIS) https://leetcode-cn.com/problems/longest-increasing-subsequence/submissions/ //GO //经典DP 线性DP //dp[i] 那么 nums[i] 必然要大于 nums[ 阅读全文

posted @ 2020-04-19 15:04 wsw_seu 阅读(218) 评论(0) 推荐(0) 编辑

导航

< 2025年2月 >
26 27 28 29 30 31 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 1
2 3 4 5 6 7 8
点击右上角即可分享
微信分享提示