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

[CareerCup] [第二轮] 2/25-3/3 CareerCup 1.8

全局:

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

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

x
Assume you have a method isSubstring which checks if one word is a substring of another. Given two strings, s1 and s2, write code to check if s2 is a rotation of s1 using only one call to isSubstring (e.g., "waterbottle" is a rotation of "erbottlewat").

发帖规范:
http://www.1point3acres.com/bbs/thread-48094-1-1.html
http://www.1point3acres.com/bbs/thread-32423-1-1.html

评分

参与人数 1大米 +10 收起 理由
Kimurate + 10

查看全部评分


上一篇:有谁也在看head first Java吗?问一道数据结构习题!!
下一篇:[第二轮] 2/25-3/3 CareerCup 2.1
🔗
mazl123321 2013-2-24 11:38:31 | 只看该作者
全局:
1. two string should always have same length

2. ppl can always check if the "waterbottle" is a substring of "erbottlewat" concatenate with "erbottlewat";


https://gist.github.com/mazl123321/5022442
回复

使用道具 举报

🔗
grassgigi 2013-2-24 13:24:51 | 只看该作者
全局:
if function SubString(s1, s2) is used to check whether s2 is a substring of s1, then call it as SubString(s1+s1, s2);
https://gist.github.com/chrislukkk/5022525
回复

使用道具 举报

🔗
莫有逆臣 2013-2-24 13:49:25 | 只看该作者
全局:
Same idea as ls~, but also we have to check the length first.
https://gist.github.com/krisliu/5022784
回复

使用道具 举报

🔗
ThunderXu 2013-2-24 15:52:55 | 只看该作者
全局:
https://gist.github.com/ThunderXu/5023045
1. Judge whether two strings equal in length
2. Judge whether two strings equals, if equal return true, else return IsSubString(s2+s2,s1)
回复

使用道具 举报

🔗
moophis 2013-2-24 17:10:55 | 只看该作者
全局:
The method is the same with others。
https://github.com/moophis/careercup/blob/master/1.8.cpp
回复

使用道具 举报

🔗
liuzhe1218 2013-2-25 09:19:23 | 只看该作者
全局:
https://gist.github.com/mettaworld/5026684
Java language
write a algorithm to judge whether a word is the substring of the other.
Then judge the rotation with two criteria: First compare their length, then judge whether waterbottle is the substring of erbottle"waterbottle"wat
回复

使用道具 举报

🔗
Kimurate 2013-2-25 10:31:26 | 只看该作者
全局:
回复

使用道具 举报

🔗
 楼主| Fanyare 2013-2-25 11:58:50 | 只看该作者
回复

使用道具 举报

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

本版积分规则

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