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

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

🔗
zuohr 2013-2-18 17:38:49 | 只看该作者
全局:
Arthur2012 发表于 2013-2-18 13:43
Hi, I have a question. What's the result if the test case is "aaab"? I think that it is still "aaa ...

yes, result of "aaab" is still "aaab".
回复

使用道具 举报

🔗
Arthur2012 2013-2-18 19:34:27 | 只看该作者
全局:
zuohr 发表于 2013-2-18 17:38
yes, result of "aaab" is still "aaab".

thx and thx.
回复

使用道具 举报

全局:
When string is not empty: if two adjacent char are the same, add 1 to count. else add this former char and count to the result string.

https://gist.github.com/lynntian/4981376
回复

使用道具 举报

🔗
moophis 2013-2-19 15:27:53 | 只看该作者
全局:
Traverse through the string while counting number of consecutive identical characters and rearrange the string.
https://github.com/moophis/careercup/blob/master/1.5.cpp
回复

使用道具 举报

🔗
moophis 2013-2-19 15:31:14 | 只看该作者
全局:
Arthur2012 发表于 2013-2-18 13:55
Transform origin string into new string by counting the number of different successive characteristi ...

Try to use sprintf() to simplify your change_int_to_string() procedure. Just a suggestion.

评分

参与人数 1大米 +5 收起 理由
Kimurate + 5 thx. it helped.

查看全部评分

回复

使用道具 举报

🔗
Arthur2012 2013-2-19 15:48:06 | 只看该作者
全局:
have updated the program and thank you for your advice.
回复

使用道具 举报

🔗
liuzhe1218 2013-2-20 13:50:33 | 只看该作者
全局:
https://gist.github.com/mettaworld/4993226
Java language
I use a char array to store different chars and int array to store their numbers. Then Output them.

点评

good idea, but i think you may take another array to hold the result.  发表于 2013-2-20 14:34
回复

使用道具 举报

🔗
Kimurate 2013-2-20 14:24:34 | 只看该作者
全局:
C language: https://gist.github.com/hukun01/4993085
* Method: First calculate the length compressed string,
* if the length is smaller than that of the original,
* compress it by accounting every char in the array and put
* the result in a new array; else return the original.
kind of messy..
回复

使用道具 举报

🔗
liuzhe1218 2013-2-20 18:16:51 | 只看该作者
全局:
Kimurate 发表于 2013-2-20 14:24
C language: https://gist.github.com/hukun01/4993085
* Method: First calculate the length compresse ...

Thank u for your opinion, I have made a little change here to output the chars with a string
https://gist.github.com/mettaworld/4993226
回复

使用道具 举报

🔗
youling_tong 2013-2-22 06:33:17 | 只看该作者
全局:

点评

nice job. just one thing: i think it would be better if the method returns a String instead of a StringBuffer  发表于 2013-2-22 10:08
回复

使用道具 举报

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

本版积分规则

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