上一页 1 ··· 12 13 14 15 16 17 18 19 20 ··· 43 下一页

2020年4月26日

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 阅读(95) 评论(0) 推荐(0) 编辑

2020年4月23日

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 阅读(186) 评论(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 阅读(128) 评论(0) 推荐(0) 编辑

2020年4月22日

1、线性DP 354. 俄罗斯套娃信封问题

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

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

2020年4月21日

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 阅读(166) 评论(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 阅读(229) 评论(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 阅读(130) 评论(0) 推荐(0) 编辑

2020年4月20日

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 阅读(137) 评论(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 ··· 12 13 14 15 16 17 18 19 20 ··· 43 下一页

导航