Skip to content

Category Archives: Arrays

Given an array of digits (values are from 0 to 9), find the minimum possible sum of two numbers formed from digits of the array.… Read More
Given an array of positive integers, find maximum possible value K such that the array has at-least K elements that are greater than or equal… Read More
Given a set of strings, find the longest common prefix. Input : {“geeksforgeeks”, “geeks”, “geek”, “geezer”} Output : "gee" Input : {"apple", "ape", "april"} Output… Read More
Given a set of strings, find the longest common prefix. Examples: Input : {“geeksforgeeks”, “geeks”, “geek”, “geezer”} Output : "gee" Input : {"apple", "ape", "april"}… Read More
Given an array, find the number of subarrays whose sum is even. Example :  Input : arr[] = {1, 2, 2, 3, 4, 1} Output… Read More
Prerequisites : LCS, LIS Given two arrays, find length of the longest common increasing subsequence [LCIS] and print one of such sequences (multiple sequences may… Read More
Given an array of integers, find two non-overlapping contiguous sub-arrays such that the absolute difference between the sum of two sub-arrays is maximum. Example: Input:… Read More
Given an array arr[] of n numbers and an integer k, find length of the minimum sub-array with gcd equals to k. Example: Input: arr[]… Read More
Given k sorted lists of integers of size n each, find the smallest range that includes at least element from each of the k lists.… Read More
Given an array of distinct elements and a number x, find if there is a pair with a product equal to x. Examples : Input… Read More
Given an integer array, find a maximum product of a triplet in array. Examples:  Input: [10, 3, 5, 6, 20] Output: 1200 Multiplication of 10,… Read More
Given an array, count number of pairs that can be formed from all possible contiguous sub-arrays containing distinct numbers. The array contains positive numbers between… Read More
Given a sorted array of integers, return the number of distinct absolute values among the elements of the array. The input can contain duplicates values.… Read More
Given an array of positive and negative numbers, arrange them in an alternate fashion such that every positive number is followed by negative and vice-versa.… Read More
Problem: Find all the subsets of a given set. Input: S = {a, b, c, d} Output: {}, {a} , {b}, {c}, {d}, {a,b}, {a,c},… Read More