# Category Archives: Divide and Conquer

## Least root of given quadratic equation for value greater than equal to K

Given the constants of quadratic equation F(x) = Ax2 + Bx + C as A, B, and C and an integer K, the task is… Read More »

QuickSort is a popular sorting technique based on divide and conquer algorithm. In this technique, an element is chosen as a pivot and the array… Read More »

## Calculate weight of parenthesis based on the given conditions

Given a valid parenthesis string S, the task is to find the weight of parenthesis based on the following conditions: Weight of “( )” is… Read More »

## Minimum cost of reducing Array by merging any adjacent elements repetitively

Given an array arr[] of N numbers. We can merge two adjacent numbers into one and the cost of merging the two numbers is equal… Read More »

## Count of unordered pairs (x, y) of Array which satisfy given equation

Given an array arr[] of N integers both positive and negative, our task is to find the number of unordered pairs (x, y) which satisfy… Read More »

## Divide N into K parts in the form (X, 2X, … , KX) for some value of X

Given a positive integer N and K, the task is to divide N into K parts such that the first part has a value X,… Read More »

## Count of groups among N people having only one leader in each group

Given N number of people, the task is to count the number of ways to form groups of size ≤ N where, in each group,… Read More »

## Change in Median of given array after deleting given elements

Given two arrays arr1[] and arr2[]. The array arr1[] is sorted. The task is to print the change in median after removing each element from… Read More »

## How to implement text Auto-complete feature using Ternary Search Tree

Given a set of strings S and a string patt the task is to autocomplete the string patt to strings from S that have patt… Read More »

## Fast Doubling method to find the Nth Fibonacci number

Given an integer N, the task is to find the N-th Fibonacci numbers. Examples: Input: N = 3 Output: 2 Explanation: F(1) = 1, F(2)… Read More »

## Longest subarray having sum K | Set 2

Given an array arr[] of size N containing integers. The task is to find the length of the longest sub-array having sum equal to the… Read More »

## Largest substring where all characters appear at least K times | Set 2

Given a string str and an integer K, the task is to find the length of the longest sub-string S such that every character in… Read More »

## Split a given array into K subarrays minimizing the difference between their maximum and minimum

Given a sorted array arr[] of N integers and an integer K, the task is to split the array into K subarrays such that the… Read More »

## Sum of all array elements less than X and greater than Y for Q queries

Given a sorted array arr[], and a set Q having M queries, where each query has values X and Y, the task is to find… Read More »

## Reduce the array by deleting elements which are greater than all elements to its left

Given an array arr[] of N integers, the task is to delete the element from the given array if element to it’s left is smaller… Read More »