Just an algo -
1. start two stacks from two extreme corners of array.
2. stack1 starts from the leftmost element, the first element in stack1 is pushed at index 0.
3. stack2 starts from the rightmost corner, the first element in stack2 is pushed at index (n-1).
4. Both stacks grow (or shrink) in opposite direction.
How to check overflow
Check space between top elements of the two stacks.