Skip to content

Category Archives: Algorithms

Given an array of size n, find all elements in array that appear more than n/k times. For example, if the input arrays is {3,… Read More
  Given an array of size n, generate and print all possible combinations of r elements in array. For example, if input array is {1,… Read More
  Evaluate an expression represented by a String. The expression can contain parentheses, you can assume parentheses are well-matched. For simplicity, you can assume only… Read More
Given n dice each with m faces, numbered from 1 to m, find the number of ways to get sum X. X is the summation… Read More
Given an array of integers. Find a peak element in it. An array element is a peak if it is NOT smaller than its neighbours.… Read More
Given an array of integers, sort the array according to frequency of elements. For example, if the input array is {2, 3, 2, 4, 5,… Read More
Given two strings ‘X’ and ‘Y’, find the length of the longest common substring.  Examples :  Input : X = “GeeksforGeeks”, y = “GeeksQuiz” Output :… Read More
Given a string str, the task is to find the minimum number of characters to be inserted to convert it to palindrome. Before we go… Read More
Following is a typical recursive implementation of QuickSort for arrays. The implementation uses last element as pivot.  C++ /* A typical recursive implementation of Quicksort… Read More
Given two binary strings that represent value of two integers, find the product of two strings. For example, if the first bit string is “1100”… Read More
Given two strings where first string may contain wild card characters and second string is a normal string. Write a function that returns true if… Read More
Find the largest rectangular area possible in a given histogram where the largest rectangle can be made of a number of contiguous bars. For simplicity,… Read More
Given an integer, write a function that returns true if the given number is palindrome, else false. For example, 12321 is palindrome, but 1451 is… Read More
Given a number N having only one ‘1’ and all other ’0’s in its binary representation, find position of the only set bit. If there… Read More
Standard C library provides qsort() that can be used for sorting an array. As the name suggests, the function uses QuickSort algorithm to sort the… Read More