查看: 2424| 回复: 13
跳转到指定楼层
上一主题 下一主题
收起左侧

[CareerCup] [第二轮] 3/4-3/10 CareerCup 3.1

全局:

注册一亩三分地论坛,查看更多干货!

您需要 登录 才可以下载或查看附件。没有帐号?注册账号

x
Describe how you could use a single array to implement three stacks.



发帖规范:
http://www.1point3acres.com/bbs/thread-48094-1-1.html
http://www.1point3acres.com/bbs/thread-32423-1-1.html


上一篇:[第二轮] 3/4-3/10 CareerCup 2.7
下一篇:[第二轮] 3/4-3/10 CareerCup 3.2
🔗
EchoMemory 2013-3-3 20:52:04 | 只看该作者
全局:
分成三份,用变量维护下栈顶和栈底上下标,模拟下栈就好了?这题是考实现么还是什么?。。single array可以用Dynamic arrays搞一下么。。。?
回复

使用道具 举报

🔗
grassgigi 2013-3-4 05:24:31 | 只看该作者
全局:
all elements in a stack could be represented in array using two array slots:
for stack element obj
a[i] = value of obj
a[i+1] = the index of next stack element below obj in stack.
so we should reserve first 3 array slots for 3 stacks, each slot points to the array index of top element in one stack.
回复

使用道具 举报

🔗
lazyGoose 2013-3-5 01:48:32 | 只看该作者
全局:
1. Divide An array into three parts. And define  "stackSize = 5"
2. Then, starting position of three stack is 0, stackSize, stackSize * 2

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

使用道具 举报

🔗
leonsu777 2013-3-5 06:42:18 | 只看该作者
回复

使用道具 举报

🔗
sunnyroom 2013-3-7 16:03:32 | 只看该作者
全局:
哎,
好多题目都看不懂是什么意思。。。。。
包括这道。。。。
智商是硬伤啊
回复

使用道具 举报

🔗
sunnyroom 2013-3-7 16:33:23 | 只看该作者
全局:
leonsu777 发表于 2013-3-5 06:42
https://github.com/longwei/Algo/ ... rrayThreeStack.java
.

可不可以讲一讲这个题目是什么意思啊
回复

使用道具 举报

🔗
ThunderXu 2013-3-7 20:33:25 | 只看该作者
全局:
The first stack use the left-most element to be bottom and grow from left to right, the second stack use the right-most element as bottom and grow from right to left, the third stack is in the middle of array, its position will have to change if there is not enought space.
回复

使用道具 举报

🔗
cynthiamo 2013-3-8 04:58:07 | 只看该作者
全局:
可不可以这样。
stack的0,1,2位分别是stack1,2,3的head,当有data插入stack2的时候,stack3head就向后移一位,当有data进入stack1的时候,stack2head and stack3head就向后各移一位。
回复

使用道具 举报

🔗
Fanyare 2013-3-9 09:41:16 | 只看该作者
全局:
回复

使用道具 举报

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

本版积分规则

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