查看: 1593| 回复: 5
跳转到指定楼层
上一主题 下一主题
收起左侧

[CareerCup] 【第三轮】8.3-8.9 CareerCup 9.8

全局:

注册一亩三分地论坛,查看更多干货!

您需要 登录 才可以下载或查看附件。没有帐号?注册账号

x
9.8 Given an infinite number of quarters (25 cents), dimes (10 cents), nickels (5 cents) and pennies (1 cent), write code to calculate the number of ways of representing n
cents

回复解法可以按照以下格式来



【解题思路】
【时间复杂度】
【空间复杂度】
【gist link】
---------------OPTional,如果觉得test case比较好,欢迎写出来分享----------------------
【test case】



上一篇:【第三轮】8.3-8.9 CareerCup 9.7
下一篇:【第三轮】8.3-8.9 CareerCup 9.9
全局:
【解题思路】
Reduce the original problem to sub-problems.
first use coins who have greater value  and the nuser coins with less value to make up the remaining value


【时间复杂度】
O(n)


【空间复杂度】
O(n)


【gist link】
https://gist.github.com/happyWinner/d1838f0faa48cc85c939

回复

使用道具 举报

🔗
ivycheung1208 2014-8-11 01:23:04 | 只看该作者
全局:
【解题思路】
1. recuision输出所有组合
2. only return number of ways of representations
--2.1 recursion
--2.2 DP keep track of results of the sub-problems
【时间复杂度】
O(N) - DP
【空间复杂度】
O(4N) - DP
【gist link】
https://gist.github.com/75356cc3be9d937e04d5


补充内容 (2014-8-17 09:17):
Thanks!! 本来想说这样更具体一点…lol

点评

Big o notation should ignore the constant factor:)  发表于 2014-8-17 12:53
回复

使用道具 举报

🔗
bitcpf 2014-9-23 00:59:48 | 只看该作者
全局:
【解题思路】From the book
Use larger coins first
f(n):=
n > 25 f(n-25)+25 ...
【时间复杂度】
O(n)
【空间复杂度】
O(n)
【gist link】
https://gist.github.com/bitcpf/9ac3344682a848d8bf05

有人做过怎么把所有组合打出来的么?
回复

使用道具 举报

🔗
Jason_Yuan 2015-8-20 16:26:27 | 只看该作者
全局:
有没有人能指点一下这道题的时间复杂度怎么估算出来的,对于这一章的时间复杂度计算都比较迷糊。难道都是用master theorem? 求大神指点一二
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册账号
隐私提醒:
  • ☑ 禁止发布广告,拉群,贴个人联系方式:找人请去🔗同学同事飞友,拉群请去🔗拉群结伴,广告请去🔗跳蚤市场,和 🔗租房广告|找室友
  • ☑ 论坛内容在发帖 30 分钟内可以编辑,过后则不能删帖。为防止被骚扰甚至人肉,不要公开留微信等联系方式,如有需求请以论坛私信方式发送。
  • ☑ 干货版块可免费使用 🔗超级匿名:面经(美国面经、中国面经、数科面经、PM面经),抖包袱(美国、中国)和录取汇报、定位选校版
  • ☑ 查阅全站 🔗各种匿名方法

本版积分规则

>
快速回复 返回顶部 返回列表