Category: DSA Questions

Delete middle element of a stack

You are given a stack and you have to delete the middle element of a stack. Example 1: Example 2: Approach: Find out the size...

Equal Coins

Chef has X coins worth 1 rupee each and Y coins worth 2 rupees each. He wants to distribute all of these X+Y coins to his two sons so that the total value of coins...

Reverse First K elements of Queue

Given an integer K and a queue of integers, we need to reverse the order of the first K elements of the queue, leaving the other elements in the same relative...

To find the Unique Number in an Array

Question: Given an array of N integers that contains duplicate values, you have to find the number that is unique to the array. Example: To...

Rotate Doubly Linked List

Given a doubly-linked list, rotate the linked list counter-clockwise by P nodes. Here P is a given positive integer and is smaller than the count...

k largest elements

Given an array, Arr of N positive integers, find K largest elements from the array.  The output elements should be printed in decreasing order. Example 1: Example 2: Input: N = 7,...

Segregate 0s and 1s

Given an array of length N consisting of only 0s and 1s in random order. Modify the array to segregate 0s on the left side and 1s...