Skip to content

Category Archives: Algorithms

Here the function takes two parameters n and k and returns the value of Binomial Coefficient C(n, k).  Example:  Input: n = 4 and k… Read More
Given a string, find the longest substring which is a palindrome.  Example: Input: Given string :”forgeeksskeegfor”, Output: “geeksskeeg” Input: Given string :”Geeks”, Output: “ee” Recommended Practice Longest… Read More
Following is a typical recursive implementation of Quick Sort that uses last element as pivot.   C++ // CPP code for recursive function of Quicksort #include… Read More
Java // Java implementation of iterative quick sort class IterativeQuickSort {  void swap(int arr[], int i, int j)  {   int t = arr[i];   arr[i] =… Read More
C // An iterative implementation of quick sort #include <stdio.h>   // A utility function to swap two elements void swap(int* a, int* b) {… Read More
Given an unsorted array of positive integers, find the number of triangles that can be formed with three different array elements as three sides of… Read More
Given an array, write a program to generate a random permutation of array elements. This question is also asked as “shuffle a deck of cards”… Read More
Given a string, print all permutations of it in sorted order. For example, if the input string is “ABC”, then output should be “ABC, ACB,… Read More
Given a string str, find its rank among all its permutations when sorted lexicographically. Note: The characters a string are all unique. Examples: Input: str… Read More
  Given an array where every element occurs three times, except one element which occurs only once. Find the element that occurs once. The expected… Read More
Given a number N, the task is to check if it is divisible by 7 or not.Note: You are not allowed to use the modulo… Read More
Given two sorted arrays, a[] and b[], the task is to find the median of these sorted arrays, where N is the number of elements… Read More
Given N machines. Each machine contains some numbers in sorted form. But the amount of numbers, each machine has is not fixed. Output the numbers… Read More
Given a book of words. Assume you have enough main memory to accommodate all words. design a data structure to find top K maximum occurring… Read More
You are given a set of n types of rectangular 3-D boxes, where the i^th box has height h(i), width w(i) and depth d(i) (all… Read More

Start Your Coding Journey Now!