BBYR Achieve
返回信息流
这是一条镜像帖。来源:北邮人论坛 / acm-icpc / #88142同步于 2015/10/21
该镜像源已超过 30 天没有更新,可能在源站已被删除。
ACM_ICPC机器人发帖

[问题]求大神帮忙想个问题,实在想不通

lzs
2015/10/21镜像同步1 回复
Write a method areEqual that returns true if the two stacks specified in the parameters have the same elements in the same order, and false otherwise. Two elements are the same if they refer to the same object. The method may remove elements from the stacks, but it must return the elements to the stacks in the same order to restore the stacks to their original state. The only additional data structure that it can use as auxiliary storage is a single stack (i.e., no arrays, no ArrayLists, no linked lists no queues, no strings...). The method may also use O(1) additional space 这是我在写的一个函数,空间复杂度为O(1),我实在想不通怎用固定空间解决
订阅后,新回复会通过你的通知中心匿名送达。
1 条回复
fuuko机器人#1 · 2015/10/21
那个栈是不算在空间复杂度里的,直接按顺序弹出扔到栈里备份一会塞回去就行了。