由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - Newest coding problem
相关主题
问个算法题2leetcode里, backtracking的time complexity怎么算,比如permutations这题目
Coding Problems(要简洁明了,不需要性能)一道coding test题
Interview question: N-sum求教一个combination的问题,求好方法
0/1 Knapsack问题Linear Space的算法可以实现Backtrack吗?问个编程题
Ask a amazon question from careercup.k-sum subset problem solution?
Algorithm Problemleetcode上一题,求正解
请教leetcode Combination Sum II的code,谢谢。求教combination两种算法的complexity (leetcode)
想问问大家如何提高Problem Reduction 能力。combination sum II
相关话题的讨论汇总
话题: newest话题: cash话题: dp话题: point话题: int
进入JobHunting版参与讨论
1 (共1页)
s*i
发帖数: 5025
1
You were given 858 points to buy 'cash'. Here is the available lots that you
can only choose from:
(cash value : points required)
$25 28p
$50 53p
$75 78p
$100 103p
$250 255p
$500 510p
Find the best combination so that you get max $. What is the time complexity?
h***k
发帖数: 161
2
naive solution:dfs找出所有组合再扫一遍找最大的。。。
请问这是哪家的题目?
p**p
发帖数: 742
3
Isn't it just a regular backsack problem?

you
complexity?

【在 s*i 的大作中提到】
: You were given 858 points to buy 'cash'. Here is the available lots that you
: can only choose from:
: (cash value : points required)
: $25 28p
: $50 53p
: $75 78p
: $100 103p
: $250 255p
: $500 510p
: Find the best combination so that you get max $. What is the time complexity?

w***n
发帖数: 58
4
据这个题目只用25即可
s*i
发帖数: 5025
5
显然不是

[发表自未名空间手机版 - m.mitbbs.com]

【在 w***n 的大作中提到】
: 据这个题目只用25即可
f*********0
发帖数: 17
6
写了个dp的方法:
dp[i] 表示用i个point最多能买到的cash。复杂度是O(拥有的point数 * 物品数)。
这个和背包问题完全一样啊。
Reply wsnmn, 注意这里使用point买cash,不是用cash买point。
int knapsack(vector &cash, vector &point) {
int dp[859] = {0};
int n = cash.size();
for (int i = 1; i <= 858; ++i) {
for (int j = 0; j < n; ++j) {
if (i-point[j] >=0) {
dp[i] = max(dp[i], dp[i-point[j]]+cash[j]);
}
}
}
return dp[858];
}
f*********0
发帖数: 17
7
有什么tricky的地方吗? 为啥说是newest coding problem。求指导

you
complexity?

【在 s*i 的大作中提到】
: You were given 858 points to buy 'cash'. Here is the available lots that you
: can only choose from:
: (cash value : points required)
: $25 28p
: $50 53p
: $75 78p
: $100 103p
: $250 255p
: $500 510p
: Find the best combination so that you get max $. What is the time complexity?

b******g
发帖数: 3616
8
显然不能只用25吧。。。反过来如果是用cash buy point那是只用25就行了。。。

【在 w***n 的大作中提到】
: 据这个题目只用25即可
s*i
发帖数: 5025
9
版上没见过这道题

【在 f*********0 的大作中提到】
: 有什么tricky的地方吗? 为啥说是newest coding problem。求指导
:
: you
: complexity?

1 (共1页)
进入JobHunting版参与讨论
相关主题
combination sum IIAsk a amazon question from careercup.
leetcode一题,自己编译没问题,leetcode总是编译出错。请高手看看Algorithm Problem
这个Generate Parentheses非递归的方法咋写请教leetcode Combination Sum II的code,谢谢。
有人能解释下Generate Parentheses的DP解法么?想问问大家如何提高Problem Reduction 能力。
问个算法题2leetcode里, backtracking的time complexity怎么算,比如permutations这题目
Coding Problems(要简洁明了,不需要性能)一道coding test题
Interview question: N-sum求教一个combination的问题,求好方法
0/1 Knapsack问题Linear Space的算法可以实现Backtrack吗?问个编程题
相关话题的讨论汇总
话题: newest话题: cash话题: dp话题: point话题: int