# Category Archives: Divide and Conquer

## Find the number of different numbers in the array after applying the given operation q times

Given an array of size N, initially consists of zeroes only. The task is to apply given operation q times and find the number of… Read More »

## Maximum Sum SubArray using Divide and Conquer | Set 2

Given an array arr[] of integers, the task is to find the maximum sum sub-array among all the possible sub-arrays. Examples: Input: arr[] = {-2,… Read More »

## Interactive Problems in Competitive Programming

Interactive Problems are those problems in which our solution or code interacts with the judge in real time. When we develop a solution for an… Read More »

## Lazy Propagation in Segment Tree | Set 2

Given an array arr[] of size N. There are two types of operations: Update(l, r, x) : Increment the a[i] (l <= i <= r)… Read More »

## Maximum element in a sorted and rotated array

Given a sorted array arr[] of distinct elements which is rotated at some unknown point, the task is to find the maximum element in it.… Read More »

## IntroSort or Introspective sort

Introsort(Introspective sort) is a comparison based sort that consists of three sorting phases. They are Quicksort, Heapsort, and Insertion sort. Basic concepts of Introsort and… Read More »

## Largest number N which can be reduced to 0 in K steps

Given an integer N. The following tasks are performed: The number is noted. The leading digit from N is subtracted from N and the resulting… Read More »

## Find 2^(2^A) % B

Given two integers A and B, the task is to calculate 22A % B. Examples: Input: A = 3, B = 5 Output: 1 223… Read More »

## Find the value of XXXX…..(N times) % M where N is large

Given three integers X, N and M. The task is to find XXX…(N times) % M where X can be any digitfrom the range [1,… Read More »

## Minimum steps to delete a string by deleting substring comprising of same characters

Given a string str. You are allowed to delete only some contiguous characters if all the characters are same in a single operation. The task… Read More »

## Sum of i * countDigits(i)^2 for all i in range [L, R]

Given a range [L, R], the task is to find the sum i * countDigits(i)2 for all i ∈ [L, R] where countDigits(i) is the… Read More »

## Search element in a Spirally sorted Matrix

Given a spirally sorted matrix with N * N elements and an integer X, the task is to find the position of this given integer… Read More »

## Merge K sorted arrays of different sizes | ( Divide and Conquer Approach )

Given k sorted arrays of different length, merge them into a single array such that the merged array is also sorted. Examples: Input : {{3,… Read More »

## Generate a random permutation of elements from range [L, R] (Divide and Conquer)

Given a range [L, R] where L ≤ R, the task is to generate a random permutation of the sequence [L, L + 1, L… Read More »

## Merge K sorted arrays | Set 3 ( Using Divide and Conquer Approach )

Giving k sorted arrays, each of size N, the task is to merge them into a single sorted array. Examples: Input: arr[][] = {{5, 7,… Read More »