由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - Target coins
相关主题
Given coins of value {k1, k2, ..., km}, 用最少硬币数组成一个sum 咋做啊F家的一道题。看起来好像很凶残的样子。求大家给思路给想法。。囧
说说某著名软件公司的onsite面试找零钱dp的问题
关于DP的问题问道硬币题目
问个epic的coin change面试题An online coding test problem
再问个coin change的问题烙印太烂了
这个题目怎么做的啊?攒人品,回答问题
cc150 Find all combinations of coins问题how to obtain a subarray whose sum is a specific given number?
求高手帮忙,一个算法问题这个怎么弄?
相关话题的讨论汇总
话题: coins话题: target话题: greedy话题: int话题: find
进入JobHunting版参与讨论
1 (共1页)
c***2
发帖数: 838
1
Given a list of coins such as 25, 10, 5, 1
find the minimum number of coins for a target value such as 95.
c**y
发帖数: 172
2
For this problem, greedy algo. works. Always choose the largest coin that is
allowed.
However,for some special sets of coins, such as 25, 10, 7, 5, 1, the greedy
algo. doesn't work. So we need to use dynamical programming to solve this
problem.

【在 c***2 的大作中提到】
: Given a list of coins such as 25, 10, 5, 1
: find the minimum number of coins for a target value such as 95.

y***m
发帖数: 7027
3
how about this
如果list很大,不要求subarray,就根据coin value 先找出对应的数字组合,从最小组
合开始对list搜索
如果要求subarray 就简单dp..

is
greedy

【在 c**y 的大作中提到】
: For this problem, greedy algo. works. Always choose the largest coin that is
: allowed.
: However,for some special sets of coins, such as 25, 10, 7, 5, 1, the greedy
: algo. doesn't work. So we need to use dynamical programming to solve this
: problem.

i**9
发帖数: 351
4
//coins sort in reverse order
int coins[]={25,10,5,1};
bool findcoinlist(int coins[],int n,int target){
int i=0;
do{
// greedy to find max coin
for(i=0;i if(target>=coins[i]){
break;
}
}
cout< target-=coins[i];
if(target==0){
return true;
}
}while(target>0);
return false;
}

【在 c***2 的大作中提到】
: Given a list of coins such as 25, 10, 5, 1
: find the minimum number of coins for a target value such as 95.

c***2
发帖数: 838
5
RE this.
Eventually we still need to find all possible combinations, then find min

is
greedy

【在 c**y 的大作中提到】
: For this problem, greedy algo. works. Always choose the largest coin that is
: allowed.
: However,for some special sets of coins, such as 25, 10, 7, 5, 1, the greedy
: algo. doesn't work. So we need to use dynamical programming to solve this
: problem.

1 (共1页)
进入JobHunting版参与讨论
相关主题
这个怎么弄?再问个coin change的问题
考古问几道题这个题目怎么做的啊?
做了一下 Google 的 Best Time to Buy and Sell Stock IIcc150 Find all combinations of coins问题
lintcode subarray sum 怎么做?求高手帮忙,一个算法问题
Given coins of value {k1, k2, ..., km}, 用最少硬币数组成一个sum 咋做啊F家的一道题。看起来好像很凶残的样子。求大家给思路给想法。。囧
说说某著名软件公司的onsite面试找零钱dp的问题
关于DP的问题问道硬币题目
问个epic的coin change面试题An online coding test problem
相关话题的讨论汇总
话题: coins话题: target话题: greedy话题: int话题: find