## N/3 repeated number in an array with O(1) space

We are given a read only array of n integers. Find any element that appears more than n/3 times in the array in linear time… Read More »

We are given a read only array of n integers. Find any element that appears more than n/3 times in the array in linear time… Read More »

Given an array, find the maximum difference between its two consecutive elements in its sorted form. Examples: Input : arr[] = {1, 10, 5} Output… Read More »

Given an array A[] of n elements and an integer k. The task is to find the number of triplet (x, y, k), where 0… Read More »

Given two strings s1 and s2, check if s1 is a suffix of s2. Or in simple words we need to find whether string s2… Read More »

Given a string s, print reverse of string and remove the characters from the reversed string where there are vowels in the original string. Examples:… Read More »

Given two arrays among which one is almost sorted with one element being in the wrong position making the array unsorted, the task is to… Read More »

Given an array whose elements represents the coefficients of a polynomial of degree n, if the polynomial has a degree n then the array will… Read More »

How to apply STL binary_search to vector of pairs(key, value), given that vector is sorted by its first value(key) struct compare in the code contains… Read More »

Given an array of positive distinct integers. We need to find the only element whose replacement with any other value makes array elements distinct consecutive.… Read More »

You are given an array of size ‘n’. You have to replace every pair of consecutive values ‘x’ by a single value ‘x+1’ every time… Read More »

Given a string s we have to find the length of the longest substring of s which contain exactly K distinct vowels. Examples: Input :… Read More »

Given an array arr[]. Find maximum value of prefix sum which is also suffix sum for index i in arr[]. Examples : Input : arr[]… Read More »

Given an array of even number of elements, form groups of 2 using these array elements such that the difference between the group with highest… Read More »

Given an array and a value k. We have to find the maximum number of equal elements possible for the array so that we can… Read More »

Parenthesis are said to be balanced when every opening brace has a closing brace like “()()” or “(())” or “(()())” etc. Incorrect balancing includes “)(”… Read More »