码迷,mamicode.com
首页 >  
搜索关键字:house robber ii    ( 7279个结果
leetcode面试题53 - II. 0~n-1中缺失的数字
虽然是道简单题,但还是翻车了,没有看到题目的有序条件。 方法一: 公式法,O(n) class Solution { public: int missingNumber(vector<int>& nums) { int sum = accumulate(nums.begin(), nums.end( ...
分类:其他好文   时间:2020-04-16 13:05:52    阅读次数:65
[leetcode 40. 组合总和 II] 不排序使用哈希表+dfs递归 vs 排序栈+回溯
题目描述 给定一个数组 candidates 和一个目标数 target ,找出 candidates 中所有可以使数字和为 target 的组合。 candidates 中的每个数字在每个组合中只能使用一次。 说明: + 所有数字(包括目标数)都是正整数。 + 解集不能包含重复的组合。 示例 1: ...
分类:编程语言   时间:2020-04-15 13:39:29    阅读次数:70
[LeetCode] 445. 两数相加 II
自己想的太复杂了。。。。。 /** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { val = x; } * } */ cla ...
分类:其他好文   时间:2020-04-15 00:42:52    阅读次数:53
264. 丑数 II
1 //动态方程dp[i]=min(dp[p_2]*2,dp[p_3]*3,dp[p_5]*5) 2 class Solution 3 { 4 public: 5 int nthUglyNumber(int n) 6 { 7 vector<int> dp(n); 8 dp[0] = 1; 9 int ...
分类:其他好文   时间:2020-04-14 20:29:05    阅读次数:60
问题 C: 幸运数字II(4,7)
问题 C: 幸运数字II 时间限制: 1 Sec 内存限制: 128 MB[提交] [状态] 题目描述 数字4和7是幸运数字,而其他的都不是幸运数字。一个整数是幸运数字,当且仅当它的十进制表示只包含幸运数字。 现在让你给出第K大的幸运数字。 输入 第一行一个整数K(1<=K<=1,000,000,0 ...
分类:其他好文   时间:2020-04-14 00:58:17    阅读次数:181
罗固P5824十二种计算方法(小球计算)
priproblem ++ i + 1n + 1有序集合链接: 如果有:(n \\\\)个球,请将它们放在\\\\(m \\\\)框中,然后找到解决方案的数量。 \\\\(\\\\文字{I ..)。球是不同的,盒子是不同的。 显然,答案是\\\\(m ^ n :)。 \\\\(\\\\文字{II . ...
分类:其他好文   时间:2020-04-13 10:48:40    阅读次数:96
113. 路径总和 II
113. 路径总和 II 给定一个二叉树和一个目标和,找到所有从根节点到叶子节点路径总和等于给定目标和的路径。 说明: 叶子节点是指没有子节点的节点。 示例:给定如下二叉树,以及目标和 sum = 22, 5 / \ 4 8 / / \ 11 13 4 / \ / \ 7 2 5 1 返回: [ [ ...
分类:其他好文   时间:2020-04-12 18:31:40    阅读次数:54
229. 求众数 II
1 class Solution 2 { 3 public: 4 vector<int> majorityElement(vector<int>& nums) 5 { 6 vector<int> res; 7 if (nums.empty()) return res; 8 // 初始化两个候选人ca ...
分类:其他好文   时间:2020-04-12 14:34:21    阅读次数:78
Search in Rotated Sorted Array II
Search in Rotated Sorted Array Problem Follow up for "Search in Rotated Sorted Array":What if duplicates are allowed? Would this affect the run-time c ...
分类:其他好文   时间:2020-04-12 14:17:08    阅读次数:54
【剑指offer】【树】68-II.二叉树的最近公共祖先
二叉树的最近公共祖先 ...
分类:其他好文   时间:2020-04-12 10:59:01    阅读次数:62
7279条   上一页 1 ... 41 42 43 44 45 ... 728 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!