高级农民
- 积分
- 2422
- 大米
- 颗
- 鳄梨
- 个
- 水井
- 尺
- 蓝莓
- 颗
- 萝卜
- 根
- 小米
- 粒
- 学分
- 个
- 注册时间
- 2015-3-12
- 最后登录
- 1970-1-1
|
【解题思路】
* Flexible division.
* the first stack start from beginning of the array and move forward like :
* Array [0,1,2,3...]
* stack1 bottom -- > top
* empty when top =-1;
*
* the second stack start from end of the array and move backward like
* Array [..... n-2,n-2,n-1]
* stack2 :top <-- bottom
* empty when top = n;
*
* The third star from in the middle of the array could be n/2 or n/3 and move forward, also
* use two pointer to know the start and the end of the stack Like
*
* Array [n/2,n/2+1,n/2+2,...]
* stack3 : bottom(start)-->top(end)
* empty end =start-1
*
* the functions will be
*
* push(stackNum, data)
*
* pop (stackNum)
*
* isEmpty(stackNum)
*
* when push data to one stack be careful to see if it collide to the boundary of the other stack.
【时间复杂度】
【空间复杂度】 |
|