• Courses
  • Tutorials
  • DSA
  • Data Science
  • Web Tech
July 08, 2022 |13.4K Views

K stacks in a single array

  Share  2 Likes
Description
Discussion

We have discussed space efficient implementation of 2 stacks in a single array.  In this post, a general solution for k stacks is discussed. Following is the detailed problem statement. Create a data structure kStacks that represents k stacks. Implementation of kStacks should use only one array, i.e., k stacks should use the same array for storing elements.

Following functions must be supported by kStacks. push(int x, int sn) –> pushes x to stack number ‘sn’ where sn is from 0 to k-1 pop(int sn) –> pops an element from stack number ‘sn’ where sn is from 0 to k-1


K stacks in a single array : https://www.geeksforgeeks.org/efficiently-implement-k-stacks-single-array/