Max stack

Problem Statement The problem “Max stack” states to design a special stack which can perform these operations : push(x): push one element into the stack. top(): returns the element that is at the top of the stack. pop(): remove the element from the stack which is at the top. peekmax(): …

Read more

Find Index of Closing Bracket for a Given Opening Bracket in an Expression

Problem Statement Given a string s of length/size n and an integer value representing the index of an opening square bracket. Find index of closing bracket for a given opening bracket in an expression. Example s = “[ABC[23]][89]” index = 0 8 s = “[C-[D]]” index = 3 5 s …

Read more

Design a stack that supports getMin() in O(1) time and O(1) extra space

Design a stack that supports getMin() in O(1) time and O(1) extra space. Thus the special stack data structure must support all the operations of the stack like – void push() int pop() bool isFull() bool isEmpty() in constant time. Add an additional operation getMin() to return the minimum value …

Read more

Reverse individual words

Problem Statement The problem “Reverse individual words” states that you are given a string s. Now, print the reverse of all the individual words in the string. Example s = “TutorialCup – changing the way of learning” puClairotuT – gnignahc eht yaw fo gninrael  s = “Reverse individual words” esreveR …

Read more

Translate »