Expression Evaluation

In expression evaluation problem, we have given a string s of length n representing an expression that may consist of integers, balanced parentheses, and binary operations ( +, -, *, / ). Evaluate the expression. An expression can be in any one of prefix, infix, or postfix notation. Example See …

Read moreExpression Evaluation

How to Create Mergable Stack?

We have to design and create a stack that performs the operations in constant time. Here we have one problem which is how to create mergable stack? Here we perform the below operation for merge two stacks. push(element): Insert the element in the stack. pop(): Remove the top element in …

Read moreHow to Create Mergable Stack?

The Stock Span Problem

This problem “The Stock Span Problem” comes under the financial aspect. In this problem, we find the stock span for the stock price of each day. The maximum number of consecutive days just before any particular day for which the price of the stock of the days before it is …

Read moreThe Stock Span Problem

Reverse a String using Stack

We have given a string s of length n which contains lower case letters, upper case letters, integers, and some special symbol. Reverse the given string using stack. Let’s see some examples for better understanding. Example Input¬† s = “TutorialCup” Output¬† puClairotuT Input s = “Stack” Output kcatS Using Stack …

Read moreReverse a String using Stack