123
返回列表 发新帖
楼主: wrj5518
跳转到指定楼层
上一主题 下一主题
收起左侧

[CareerCup] 【第三轮】6.30-7.6 CareerCup 3.6

🔗
Neal 2014-7-7 08:51:59 | 只看该作者
全局:
【解题思路】sort the first N element, pop them into the additional stack, while pushing them back, insert the N+1 element.
【时间复杂度】O(n^2)
【空间复杂度】O(n)
【gist】https://gist.github.com/nealhu/4cb80acdcfd5a95f18cb
回复

使用道具 举报

🔗
tonygxxx1212 2014-7-8 03:05:13 | 只看该作者
全局:
【解题思路】两个stack倒来倒去(详见注释),针对重复的元素,曾加了一个记录个数的变量,遇到当前最小值有多个重复时,一口气push进去
                  循环变量要主意及时更新。
【时间复杂度】 O(n^2)
【空间复杂度】O(n)
【gist link】 https://gist.github.com/xun-gong/38b5bf84b0fd034c9172
           
【test case】: 加入重复元素
回复

使用道具 举报

🔗
jason51122 2014-7-8 14:04:32 | 只看该作者
全局:
【解题思路】Insertion sort.
【时间复杂度】O(N^2)
【空间复杂度】O(N)
【gist link】https://gist.github.com/jason51122/873e2027bab8ec7c718f
回复

使用道具 举报

🔗
锦木千束 2014-7-8 18:21:07 | 只看该作者
全局:
【解题思路】
1.pop the stack1(original) to a temp
2.if temp less than stack2.peek, pop the stack2 to stack1 until the temp greater than or equal to stack2.peek,
【时间复杂度】O(n^2)
【空间复杂度】O(n)
【gist link】https://gist.github.com/weazord/eff06a1bd7bba96781de
回复

使用道具 举报

全局:
【解题思路】
when moving one element to another stack, find its position by moving elements bigger than it back to the original stack


【时间复杂度】
O(n^2)

【空间复杂度】
O(n)

【gist link】
https://gist.github.com/happyWinner/0930e886d563977b5831




评分

参与人数 1大米 +2 收起 理由
kimiflasky + 2 回答的很好!

查看全部评分

回复

使用道具 举报

🔗
renli3000 2014-7-14 03:17:06 | 只看该作者
全局:
【解题思路】
Similar to insertion sort. Use additional stack to do the insertion.

【时间复杂度】
O(n^2)
【空间复杂度】
O(n)

【gist link】
https://gist.github.com/Noahsark/6c66816d39a46930804e

回复

使用道具 举报

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

本版积分规则

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