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

[CareerCup] 【第三轮】6.23-6.29 CareerCup 2.1

🔗
jason51122 2014-6-25 13:54:51 | 只看该作者
全局:
【解题思路】Traverse the linked list from the beginning. Create a runner to remove duplicated list nodes after current node.
【时间复杂度】O(N^2)
【空间复杂度】O(1)
【gist link】https://gist.github.com/jason51122/a63189296107e55d52ec
回复

使用道具 举报

🔗
心焰 2014-6-26 08:58:55 | 只看该作者
全局:
【解题思路】
1. Use a set. Then go through the list, if the node exists in the set, remove it; otherwise, keep it and put it into the set
2. (no tmp buffer) Compare each node with the others, when encounters a dup one, remove that dup node
【时间复杂度】
1. O(N)
2.O(N^2)
【空间复杂度】
1. O(N)
2.O(1)
【gist link】
https://github.com/FinalF/CarrerUp/blob/master/listDupRemove.java
回复

使用道具 举报

🔗
pud 2014-6-26 09:43:03 | 只看该作者
全局:
【解题思路】
参考书上思路,第一种用set,add(item)只添加不重复的
第二种两次遍历linked list
【时间复杂度】
1. O(N)
2.O(N^2)
【空间复杂度】
1. O(N)
2.O(1)
【gist link】解题思路】
1. Use a set. Then go through the list, if the node exists in the set, remove it; otherwise, keep it and put it into the set
2. (no tmp buffer) Compare each node with the others, when encounters a dup one, remove that dup node
【时间复杂度】
1. O(N)
2.O(N^2)
【空间复杂度】
1. O(N)
2.O(1)
【gist link】https://gist.github.com/yokiy/078e7b4865929a15fa2d
回复

使用道具 举报

🔗
兰橘清檬 2014-6-26 14:22:26 | 只看该作者
全局:
【解题思路】
check duplication for each node in the list to avoid buffer
【时间复杂度】
O(N^2)
【空间复杂度】
O(1)
【gist link】
https://gist.github.com/JoyceeLee/51c7aee25b898ddcf699
回复

使用道具 举报

🔗
RealityPC 2014-6-27 09:56:57 | 只看该作者
全局:
1.
【解题思路】hashtable
【时间复杂度】O(N)
【空间复杂度】O(N)
2
【解题思路】two pointer
【时间复杂度】O(N^2)
【空间复杂度】O(1)
【gist link】https://gist.github.com/pchong90/ca41bc80780c2d1329ce
回复

使用道具 举报

🔗
jyh橘子 2014-6-27 12:40:33 | 只看该作者
全局:
【解题思路】
use a hashset to check duplication
follow up: brute force search
【时间复杂度】
O(N)
follow up : O(N^2)
【空间复杂度】
O(N)
follow up : O(1)
【gist link】https://gist.github.com/jyhjuzi/83a9f2ab30415da23c72
回复

使用道具 举报

🔗
ivycheung1208 2014-6-28 05:47:38 | 只看该作者
全局:
本帖最后由 ivycheung1208 于 2014-6-27 17:48 编辑

【解题思路】
iterate through the linked list and use a bool array to mark whether a character has appeared before. (ASK about the character set!)
FOLLOW UP: brute force, o(N^2)
【时间复杂度】
O(N)
【空间复杂度】
O(1)
【gist link】
https://gist.github.com/08d9198fb0f9b4bda559
【test case】
null list
回复

使用道具 举报

🔗
habina 2014-6-28 09:17:21 | 只看该作者
全局:
============================================================================
Solution        : iterate through the whole, add char to a set
                      if char already existed in set, skip this node
Time Complexity : Average Case: O(1), Worst Case: O(N)
Space Complexity: O(N)
Gist Link       : https://gist.github.com/habina/3896531754d629b2032f
============================================================================
回复

使用道具 举报

🔗
jing0328 2014-6-28 15:59:49 | 只看该作者
全局:
【解题思路】hash set to check duplicate; for follow-up, use two pointers to track
【时间复杂度】hash set O(n), two ptrs O(n^2)
【空间复杂度】hash set O(n), two ptrs O(1)
【gist link】https://gist.github.com/chrislukkk/fc2ce325c06ab6e47c1e
回复

使用道具 举报

🔗
tonygxxx1212 2014-6-30 23:48:52 | 只看该作者
全局:

【解题思路】for each node, examine all its previous nodes and check if it's a duplicate.
【复杂度】   // 1. Time: O(n), Space: O(n)
                  // Use unordered_set to record node
【复杂度】   // 2. Time: O(n^2), Space: O(1)
                  // The "Runner" Technique
【gist link】 https://gist.github.com/xun-gong/bebcd35a3874032268e7
回复

使用道具 举报

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

本版积分规则

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