Number of non-negative integral solutions of a + b + c = n
Given a number n, find number of ways we can add 3 non-negative integers so that their sum is n. Examples : Input : n… Read More »
Given a number n, find number of ways we can add 3 non-negative integers so that their sum is n. Examples : Input : n… Read More »
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 a set of strings, find the longest common prefix. Examples: Input : {“geeksforgeeks”, “geeks”, “geek”, “geezer”} Output : “gee” Input : {“apple”, “ape”, “april”}… Read More »
Given a word, find lexicographically smaller permutation of it. For example, lexicographically smaller permutation of “4321” is “4312” and next smaller permutation of “4312” is… Read More »
Prerequisite : Minimax Algorithm in Game Theory As seen in the above article, each leaf node had a value associated with it. We had stored… Read More »
Given an array of n numbers, find LCM of it. Input : {1, 2, 8, 3} Output : 24 Input : {2, 7, 3, 9,… 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 »
Given a string and a pattern, replace multiple occurrences of a pattern by character ‘X’. The conversion should be in-place and solution should replace multiple… 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 a square maze containing positive numbers, find all paths from a corner cell (any of the extreme four corners) to the middle cell. We… Read More »
Motivation To approximate the shortest path in real-life situations, like- in maps, games where there can be many hindrances. We can consider a 2D Grid… Read More »
Given an integer array, find number of ways to calculate a target number using only array elements and addition or subtraction operator. Example: Input: arr[]… Read More »
A Diophantine equation is a polynomial equation, usually in two or more unknowns, such that only the integral solutions are required. An Integral solution is… 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 »
Minimax is a kind of backtracking algorithm that is used in decision making and game theory to find the optimal move for a player, assuming… Read More »