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

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

🔗
 楼主| Fanyare 2013-2-27 02:01:47 | 只看该作者
全局:
回复

使用道具 举报

🔗
Kimurate 2013-2-27 09:09:57 | 只看该作者
全局:
Fanyare 发表于 2013-2-27 02:01
https://github.com/quantumrose/CareerCup/blob/master/2.3.DeleteNode.java

yes, and I can't figure out the bug...> <

点评

I have edited 0L to add some comment in the solution~  发表于 2013-2-27 10:01
回复

使用道具 举报

🔗
Kimurate 2013-2-27 10:52:54 | 只看该作者
全局:
Fanyare 发表于 2013-2-27 02:01
https://github.com/quantumrose/CareerCup/blob/master/2.3.DeleteNode.java

I see. I used to write the "delNode = NULL;", but it doesn't work..
回复

使用道具 举报

🔗
moophis 2013-2-27 16:45:53 | 只看该作者
全局:
Use three pointers to travel through the list such that when the most prior pointer reaches the tail, the middle pointer points to middle node, followed by the last pointer for deleting the middle.
Don't know how to handle the scenario with even nodes.
https://github.com/moophis/careercup/blob/master/2.2-3.cpp

点评

Oh, two pointers are ok. My fault.  发表于 2013-2-27 16:53
回复

使用道具 举报

🔗
sing1ee 2013-2-27 17:58:50 | 只看该作者
全局:
gist:https://gist.github.com/sing1ee/5046778

(1)delete the last node
(2)delete others 1)copy the next value to current, 2) point current next to next's next;
回复

使用道具 举报

🔗
lazyGoose 2013-2-28 01:04:32 | 只看该作者
全局:
Copy work from  mazl123321

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

使用道具 举报

🔗
weep_willow 2013-2-28 10:02:14 | 只看该作者
全局:
本帖最后由 weep_willow 于 2013-2-28 10:08 编辑

* Solution: copy the next node information to the given node and delete the next node.
* Time complexity: O(1)
这种方法的局限性在于不能删除最后一个node, 不知道大家有没有别的好的想法。
c/c++实现
https://github.com/StanleyLee/CareerCup/blob/master/2_3.cpp
回复

使用道具 举报

🔗
champoier 2013-2-28 15:08:48 | 只看该作者
全局:
把current node的next node的data copy给当前node.

https://gist.github.com/skxie/17d581ead6baab65a4fd
回复

使用道具 举报

🔗
sing1ee 2013-2-28 17:02:54 | 只看该作者
全局:
champoier 发表于 2013-2-28 15:08
把current node的next node的data copy给当前node.

https://gist.github.com/skxie/17d581ead6baab65a4f ...

Can not delete the last node.

We can delete the last node withe two pointers and one iteration and the average cost is O(1)
回复

使用道具 举报

🔗
qeroqero 2013-2-28 23:56:47 | 只看该作者
全局:
replace node C content with node D, then delete node D(Put C's next node is E)
回复

使用道具 举报

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

本版积分规则

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