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

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

🔗
 楼主| Fanyare 2013-2-22 10:05:58 | 只看该作者
全局:
回复

使用道具 举报

🔗
SunnyDay1022 2013-2-22 10:12:57 | 只看该作者
全局:
go through original string
create the compressed string
compare the length of these two
https://github.com/swang1022/car ... /strCompression.cpp
回复

使用道具 举报

🔗
lazyGoose 2013-2-22 11:32:41 | 只看该作者
全局:
一个一个拿出来,数好多少个。然后再放到一个新String里头

改了好几次,这要是面试的话,不就直接傻b了。
https://gist.github.com/lazyGoose/165981b1acf36509be29
回复

使用道具 举报

🔗
amoscoder 2013-2-22 22:33:39 | 只看该作者
全局:
本帖最后由 amoscoder 于 2013-2-22 23:13 编辑

新手学习
思路:
      新建一个数组储存字符出现的次数。然后遍历原字符串,并把字符与出现数目一同加入到新建的string当中。

https://gist.github.com/KuangyinWang/5013774





回复

使用道具 举报

🔗
yukainuo23 2013-2-23 07:20:16 | 只看该作者
全局:
https://gist.github.com/KainuoYU/5017344

Use stringbuilder to find consecutive repeating character? detelet the repeat one and count++ till next character is different or the end of the stringbuilder. Insert the counting number to the next spot of counted character.
回复

使用道具 举报

🔗
ThunderXu 2013-2-23 10:43:10 | 只看该作者
全局:
https://gist.github.com/ThunderXu/5018110
遍历的同时计数,当遇到下一个不同的字母时把当前字母和当前计数保存下来
回复

使用道具 举报

🔗
champoier 2013-2-23 12:13:13 | 只看该作者
全局:
从左往右依次扫过,字母不同了,在末尾加之前的字母和数字,长度大于之前的string,输出之前的,否则输出压缩后的。


https://gist.github.com/skxie/4e39d73a2fef27272841
回复

使用道具 举报

全局:
https://github.com/1094401996/Ca ... er/Chapter1/onedot5

此题去年做过了。。。。直接按照答案思维写的,为了达到锻炼的效果,增加了一个解压的类, 即: a1b2c3 ====> abbccc
回复

使用道具 举报

🔗
jerrysun 2013-2-23 23:41:26 | 只看该作者
全局:
https://github.com/JerrySun363/C ... CompressString.java

设了两个index start和end,将string转化成charArray然后扫,
当array【start】 和 array【end】不一样的时候,就算减肥,计算长度,并且将start设到当前end的位置
最后end=length 的时候计算最后一组
然后比较,输出。
de了一会,觉得循环有点麻烦。。。
回复

使用道具 举报

🔗
jerrysun 2013-2-23 23:43:55 | 只看该作者
全局:
规格严格理性帝 发表于 2013-2-23 15:52
https://github.com/1094401996/CareerCup/tree/master/Chapter1/onedot5

此题去年做过了。。。。直接按 ...

和楼上思路基本差不多,但是觉得countCheck基本和压缩干了同样的一件事,为何不在最后check呢...
回复

使用道具 举报

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

本版积分规则

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