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

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

全局:
qianhuang 发表于 2014-7-2 21:23
thank you for review.
PS: 怎么点评别人的帖子?我找不到这功能?

要攒够1000分升到高级农民才可以…我也是最近才发现
话说很少人用c++刷题呐 握爪
回复

使用道具 举报

🔗
兰橘清檬 2014-7-3 14:48:30 | 只看该作者
全局:
【解题思路】
用两个stack,一个专门入队,一个专门出队
【时间复杂度】
O(1)
【空间复杂度】
O(n)
【gist link】
https://gist.github.com/JoyceeLee/4cd3b04782250d47aa69
回复

使用道具 举报

🔗
jyh橘子 2014-7-4 05:43:55 | 只看该作者
全局:
【解题思路】
one stack for enqueue, the second stack for dequeue;  if the second stack is empty, pop all elements in the first stack and push to the second one.
【时间复杂度】
O(1)
【空间复杂度】
O(n)
【gist link】https://gist.github.com/jyhjuzi/0768b50cf97db7914564
回复

使用道具 举报

全局:
【解题思路】
Use one stack as the 'push' stack and another as the 'pop' stack. Push all elements to the push stack, and pop from the pop stack. When the pop stack is empty, push all elements from the push stack to the pop stack

【时间复杂度】
POP: amortized O(1), worst case O(n), Push is O(1)

【空间复杂度】
O(n)

【gist link】
https://gist.github.com/XiaoxiaoLi/fb712533a48d73b4415f
回复

使用道具 举报

🔗
bitcpf 2014-7-6 01:18:16 | 只看该作者
全局:
【解题思路】2 stacks, 1 for insert, another for deque
【时间复杂度】O(1)
【空间复杂度】O(n)
【gist link】https://gist.github.com/bitcpf/36f4295d5b02d9b14d75
回复

使用道具 举报

🔗
donnice 2014-7-6 06:05:02 | 只看该作者
全局:
【解题思路】2 stacks, enqueue & dequeue
【时间复杂度】O(1)
【空间复杂度】O(n)
【gist link】
https://github.com/donnice/donni ... 076dfe699d3994b4cf6
回复

使用道具 举报

🔗
pud 2014-7-6 10:41:39 | 只看该作者
全局:
【解题思路】
two stacks, one for enqueque, one for dequeue
【时间复杂度】
O(1)
【空间复杂度】
O(n)
【gist link】https://gist.github.com/yokiy/6e167df8c936e92241d9
回复

使用道具 举报

🔗
Neal 2014-7-6 12:23:14 | 只看该作者
全局:
【解题思路】one stack for push, one stack for poll
【时间复杂度】O(1) for push; O(n) for poll, depends on the order of operations
【空间复杂度】O(n)
【gist link】https://gist.github.com/nealhu/bdcb03625883ae62f023
回复

使用道具 举报

🔗
whiteflower 2014-7-6 19:56:08 | 只看该作者
全局:
【解题思路】
Create two stacks, stackNewest and stackOldest.
Push elements into stackNewest and pop elements
from stackOldest. If stackOldest is empty when
trying to pop, pop elements from stackNewest and
push into stackOldest.
【时间复杂度】      
enQueue  deQueue
O(1)     O(N)
【空间复杂度】O(N)
【gist link】https://gist.github.com/JoshuaTang/b0b386c99fa59f665c8a
回复

使用道具 举报

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

本版积分规则

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