## Reverse a stack without using extra space in O(n)

Problem Statement   The problem “Reverse a stack without using extra space in O(n)” states that you are given a stack data structure. Reverse the given stack without using extra O(n) space. Example   5 4 3 2 1 1 2 3 4 5 80 60 10 20 20 10 60 80 …

## Implement a stack using single queue

Problem Statement   The problem “Implement a stack using single queue” asks us to implement a stack (LIFO) data structure using a queue (FIFO) data structure. Here LIFO means Last In First Out while FIFO means First In First Out. Example   push(10) push(20) top() pop() push(30) pop() top() Top : 20 …

## Tracking current Maximum Element in a Stack

Problem Statement   “Tracking current Maximum Element in a Stack” states that you are given a stack data structure. Create a function to keep the track of the maximum value in the stack till the current index. Example   4 19 7 14 20 4 19 19 19 20 Explanation: The maximum …

## Reverse a String

Problem Statement   “Reverse a String” problem states that you are given a string s of size n. Write a program to reverse it. So, what does reversing a string means? It generally means reversing the input string that we are given. That is it is defined as an operation doing …

## Top K Frequent Words

In top K frequent words problem, we have given a list of words and an integer k. Print k most frequently used strings in the list.    Example   Input : list = {“code”, “sky”, “pen”, “sky”, “sky”, “blue”, “code”} k = 2 Output :  sky code Input : list = …

## Valid Palindrome

Given a string s of length n. Write a program to find if the string is valid palindrome or not. If not you may delete at most one character from the string to make it a palindrome. Any string which is the same as it’s reverse is known as a …

## Most Frequent Element in an Array

You are given an array of integers. The problem statement says that you have to find out the most frequent element present in an array. If there are multiple values that occurs the maximum number of times, then we have to print any of them. Example   Input [1, 4,5,3,1,4,16] Output …

## OSI Model

This model was developed in 1983 by the International Standards Organization (ISO). This was the first step taken to standardized the international protocols used in various layers. As it deals with connecting open systems, that is, systems that are open for communication with other systems, the model is called the …

## Priority Queue in C++

FIFO manner is used to implement a queue. In a queue, insertions are done at one end (rear) and deletion takes place at another end (front). Basically, the element enters first is deleted first. We implement a priority queue using c++ inbuilt functions. Characteristics of Priority Queue   A priority queue …

## Recursion

What is Recursion? Recursion is simply defined as a function calling itself. It uses its previously solved sub-problems to compute a bigger problem. It is one of the most important and tricky concepts in programming but we can understand it easily if we try to relate recursion with some real …