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

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

🔗
wilbert 2014-7-2 13:35:10 | 只看该作者
全局:
【解题思路】
three partitions: stack 1 starts from index 0 and grows to the right; stack 2 starts from 1/3*size and grows to the right, in order to enhance the array usage, this stack is movable; stack 3 starts from the end and grows to the left.
【时间复杂度】
Amortized O(1) if move stack 2 is not involved, otherwise O(N)
【空间复杂度】
O(N)
【gist link】
https://gist.github.com/iwilbert/f2e1f8627b141e38e423
回复

使用道具 举报

🔗
兰橘清檬 2014-7-3 01:43:06 | 只看该作者
全局:
【解题思路】
三个固定大小的栈
【时间复杂度】
O(1) for any operation on the stack
【空间复杂度】
O(N)
【gist link】
https://gist.github.com/JoyceeLee/35063250c87856a764f6
回复

使用道具 举报

🔗
jyh橘子 2014-7-3 05:58:22 | 只看该作者
全局:
【解题思路】
divide the array into three parts for three stacks. If one stack is full, shift the next one and make a room for the full one.
【时间复杂度】
O(1)
【空间复杂度】
O(N)
【gist link】https://gist.github.com/jyhjuzi/6dfe30952ebb223cc1e3
回复

使用道具 举报

🔗
兰橘清檬 2014-7-3 10:48:02 | 只看该作者
全局:
【解题思路】
三个可变大小的栈,可以互相借用空间
【时间复杂度】
O(1) for any operation on the stack
【空间复杂度】
O(N)
【gist link】
https://gist.github.com/JoyceeLee/c95e9541526bcb647a7f

点评

good  发表于 2014-7-7 02:05
回复

使用道具 举报

🔗
jason51122 2014-7-6 06:23:11 | 只看该作者
全局:
【解题思路】Use a circular array to shift elements when there is no room for current stack.
【时间复杂度】O(N) for push() and O(1) for other operations
【空间复杂度】O(N)
【gist link】https://gist.github.com/jason51122/b19f532fc5d4fcc3f190
回复

使用道具 举报

🔗
whiteflower 2014-7-6 19:25:29 | 只看该作者
全局:
【解题思路】 Partition the array into three equal parts, and position each stack by a pointer
【时间复杂度】O(1)
【空间复杂度】O(N)
【gist link】https://gist.github.com/JoshuaTang/2fc833043d654ab01d10
回复

使用道具 举报

🔗
guchang 2014-7-6 22:19:56 | 只看该作者
全局:
【解题思路】
三个不可变大小的stack。貌似这样难度回小很多,,呵呵
【时间复杂度】
O(1)
【空间复杂度】
O(1)
【gist link】
https://gist.github.com/guchang/29b1c82ee2604e338268
回复

使用道具 举报

🔗
Tsien 2014-7-6 23:57:20 | 只看该作者
全局:
本帖最后由 Tsien 于 2014-7-6 23:59 编辑

【发错,待修正】
//【解题思路】
//利用递归,从中间向两边走
//【时间复杂度】
//O(n)
//【空间复杂度】
//O(1)
//【gist link】
https://gist.github.com/Tsien/2b657a0bc23f0ca63350
回复

使用道具 举报

🔗
林微熙 2014-7-7 02:05:07 | 只看该作者
全局:
【解题思路】
分成三个固定大小的栈(这样其实不好,长度应是可变的)
【时间复杂度】
O(1) for any operation on the stack
【空间复杂度】
O(N)
【gist link】https://gist.github.com/hilda8519/7137b113481e228481f2
回复

使用道具 举报

🔗
tonygxxx1212 2014-7-7 06:03:19 | 只看该作者
全局:

【解题思路】
fixed-size 3 stack
【时间复杂度】
O(1) 实为数组index操作模拟
【空间复杂度】
O(1)  
【gist link】
https://gist.github.com/xun-gong/8f411da215c2de327575
回复

使用道具 举报

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

本版积分规则

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