楼主: Fanyare
跳转到指定楼层
上一主题 下一主题
收起左侧

[CareerCup] [第二轮] 2/18-2/24 CareerCup 1.1

🔗
bainikolaus 2013-2-17 21:59:56 | 只看该作者
全局:
lvchaoshuai 发表于 2013-2-17 17:36
其实C++里string的length函数是返回常量吧,并不是类似strlen来通过计算获得长度的。返回的应该是个内部常 ...

原来如此 那我还给错建议了哈哈
回复

使用道具 举报

🔗
bainikolaus 2013-2-17 22:00:27 | 只看该作者
全局:
Arthur2012 发表于 2013-2-17 17:23
恩恩,我明白了,每次都算了次str.len(),太感谢了,我现在就改

给错建议了 不好意思哈
回复

使用道具 举报

🔗
Arthur2012 2013-2-17 22:17:25 | 只看该作者
全局:
bainikolaus 发表于 2013-2-17 22:00
给错建议了 不好意思哈

呵呵,没事啦,证明我也没有深入研究清楚,anyway,谢谢啦!
回复

使用道具 举报

🔗
zuohr 2013-2-17 22:56:35 | 只看该作者
全局:
本帖最后由 zuohr 于 2013-2-17 22:57 编辑
ryancooper 发表于 2013-2-17 15:13
Wow, so quick! If we can not use additional data structures, then it seems we have to do t ...


Implementing the idea of ryancooper, which uses a bitmap boolean[] to mark the occurance of each character.
Time complexity O(N), space complexity O(N).

https://gist.github.com/anonymous/4971778

回复

使用道具 举报

🔗
lvchaoshuai 2013-2-17 22:59:52 | 只看该作者
全局:
Frankie0616 发表于 2013-2-17 21:39
call一个function的开销肯定是要比调用局部变量要慢的,所以还是增加一个局部变量好。不过这都是小问题了 ...

恩,it depends on clarity or speed~
回复

使用道具 举报

🔗
ototsuyume 2013-2-17 23:16:36 | 只看该作者
全局:
本帖最后由 ototsuyume 于 2013-2-17 23:20 编辑
lvchaoshuai 发表于 2013-2-17 17:36
其实C++里string的length函数是返回常量吧,并不是类似strlen来通过计算获得长度的。返回的应该是个内部常 ...

the time complexcity of getting the length of std::string  depends on implemention
回复

使用道具 举报

🔗
lvchaoshuai 2013-2-17 23:23:15 | 只看该作者
全局:
本帖最后由 lvchaoshuai 于 2013-2-17 23:26 编辑
ototsuyume 发表于 2013-2-17 23:16
the time complexcity of getting the length of std::string  depends on implemention

Right, but at least for the C++11 standard, it is defined as constant.
回复

使用道具 举报

🔗
mazl123321 2013-2-18 00:18:40 | 只看该作者
全局:
https://gist.github.com/mazl123321/4972058

我觉得这个题,array不算作additional data structure。
回复

使用道具 举报

🔗
bainikolaus 2013-2-18 00:39:30 | 只看该作者
全局:
cqx83 发表于 2013-2-17 16:36
https://gist.github.com/cqx83/4970678

嗯 代码清晰 结果测试了也是对的
回复

使用道具 举报

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

本版积分规则

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