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

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

全局:
jerrysun 发表于 2013-2-23 23:43
和楼上思路基本差不多,但是觉得countCheck基本和压缩干了同样的一件事,为何不在最后check呢...

因为如果压缩后的字符串没有变短的话  压缩就失去了意义 白白耗费了压缩所耗费的空间和时间。。。。
回复

使用道具 举报

全局:
jerrysun 发表于 2013-2-23 23:43
和楼上思路基本差不多,但是觉得countCheck基本和压缩干了同样的一件事,为何不在最后check呢...

也就说检测这个步骤是必须有的,你放在压缩前面,它能帮助你决定是否需要压缩。。。你如果放在压缩后面的话,如果出现了压缩后的字符串还比原始的长,那你就白压缩了。。。。觉得说的清楚的话加点分给我。。。分数太低了。。
回复

使用道具 举报

🔗
willians512 2013-2-24 08:20:08 | 只看该作者
全局:
https://gist.github.com/bigteeth/5021982

create a new string and go over the old one, append the letter and repeat times to the new string
回复

使用道具 举报

🔗
starcroce 2013-2-24 17:31:35 | 只看该作者
全局:
https://gist.github.com/starcroce/5023224
感觉下我的缺点吧,首先主要是用了buff,所以输入的字符串长度有限制。。。然后是我不大清楚题目的要求仅仅是"aaabb"->"a3b2"还是要求进一步实现"ababa"->"a3b2"这种的,我目前仅仅是比较相邻的,如果要求实现后面一种的话感觉应该可以开一个char s[26]来存每个字母出现的个数,。。。
回复

使用道具 举报

🔗
qiaobao 2013-2-25 08:12:11 | 只看该作者
全局:
1. Calculate the length of the string;2. if length < 3, return;
3. check whether the string can be compressed. If not, return;
4. create the compressed string

https://gist.github.com/Andy1989/759c7edf09452d341758
回复

使用道具 举报

🔗
yzl232 2013-2-26 11:32:20 | 只看该作者
全局:
https://gist.github.com/yzl232/5035629

用的python
也是遍历的思想。
建立了新的string

回复

使用道具 举报

🔗
sunnyroom 2013-2-26 13:11:32 | 只看该作者
全局:
tranvers the old string and copy the letter and repeated times to the new string.

https://gist.github.com/sunxw/5036072
回复

使用道具 举报

🔗
cjsp 2013-2-28 20:20:07 | 只看该作者
全局:
https://gist.github.com/flatlight/5056350
build the compressed string using StringBuilder while traversing the original string
回复

使用道具 举报

🔗
cjsp 2013-2-28 20:22:40 | 只看该作者
全局:
sunnyroom 发表于 2013-2-26 13:11
tranvers the old string and copy the letter and repeated times to the new string.

https://gist.gi ...

It might be more efficient to use StringBuilder or StringBuffer instead of String to perform the append operation in a loop
回复

使用道具 举报

🔗
sunnyroom 2013-2-28 22:24:50 | 只看该作者
全局:
cjsp 发表于 2013-2-28 20:22
It might be more efficient to use StringBuilder or StringBuffer instead of String to perform the a ...

Thanks.

with respect to String, char[], or StringBruilder, StringBuffer,
I do not know the difference between them.

回复

使用道具 举报

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

本版积分规则

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