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

[CareerCup] [第二轮] 3/4-3/10 CareerCup 2.7

全局:

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

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

x
magict 同學忘記發帖的事了,這周我來發。
2.7
Implement a function to check if a linked list is a palindrome.


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

上一篇:有人做过leetcode里的word ladder II 吗?
下一篇:[第二轮] 3/4-3/10 CareerCup 3.1
🔗
ThunderXu 2013-3-3 19:53:01 | 只看该作者
全局:
https://gist.github.com/ThunderXu/5075796
calculate the size of the list, put the former half of the list into a stack and continue pop and compare while iterating the rest half
回复

使用道具 举报

🔗
moophis 2013-3-3 21:04:58 | 只看该作者
全局:
https://github.com/moophis/careercup/blob/master/2.2-7.cpp#L418
Push all value of nodes into a stack in order, then pop each value comparing with each node in the linked list.
回复

使用道具 举报

🔗
lazyGoose 2013-3-4 09:36:48 | 只看该作者
全局:
1. If (size of LinkList) % 2 == 0,  return false
1. Separate the LinkList to two parts, the first half and the second half.
2. push the elements in second half to A stack.
3. pop the stack and compare each element with the first half. Until stack is empty.

https://gist.github.com/lazyGoose/5079309
回复

使用道具 举报

🔗
lazyGoose 2013-3-4 09:44:39 | 只看该作者
全局:
moophis 发表于 2013-3-3 21:04
https://github.com/moophis/careercup/blob/master/2.2-7.cpp#L418
Push all value of nodes into a stac ...

Hi, 我刚学C语言,用array_to_list(arr, 5, head, tail); show_list(head, tail);的时候用不用加啥头文件?
回复

使用道具 举报

🔗
liuzhe1218 2013-3-4 10:05:45 | 只看该作者
全局:
java language
https://gist.github.com/mettaworld/5079404
回复

使用道具 举报

🔗
moophis 2013-3-4 10:14:43 | 只看该作者
全局:
lazyGoose 发表于 2013-3-4 09:44
Hi, 我刚学C语言,用array_to_list(arr, 5, head, tail); show_list(head, tail);的时候用不用加啥头文件 ...

这些函数都是我自己实现的,就在源文件里,所以不需要加载其他头文件了。
回复

使用道具 举报

🔗
cjsp 2013-3-4 21:34:59 | 只看该作者
全局:
回复

使用道具 举报

🔗
 楼主| Kimurate 2013-3-4 21:55:52 | 只看该作者
全局:
* Method: Get the middle of the list, reverse the second half,
* compare the first and the second half.

C language:
https://gist.github.com/hukun01/5082379
回复

使用道具 举报

🔗
weep_willow 2013-3-5 13:00:35 | 只看该作者
全局:
* Solution: first to find the lenght of the linkedlist; then sotre the first half of the linked list in a stack, then compare with the second half of the linked list
* Time complexity: O(n);  Space complexity: O(n)

C/C++ implementation
https://github.com/StanleyLee/CareerCup/blob/master/2_7.cpp

回复

使用道具 举报

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

本版积分规则

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