# Category Archives: Divide and Conquer

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
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
Given two integers A and B, the task is to calculate 22A % B. Examples:   Input: A = 3, B = 5 Output: 1 223 % 5â€¦ Read More
Given three integers X, N and M. The task is to find XXX…(N times) % M where X can be any digit from the rangeâ€¦ Read More
Given string str. You are allowed to delete only some contiguous characters if all the characters are the same in a single operation. The taskâ€¦ Read More
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
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
Given k sorted arrays of different length, merge them into a single array such that the merged array is also sorted.Examples:  Input : {{3, 13},â€¦ Read More
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
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
Given N vertex where N is even. Initially there is no edge between any of the vertices. You are allowed to perform operation as illustrated here:  â€¦ Read More
Given a number X, the task is to find the minimum number N such that the total set bits of all numbers from 1 toâ€¦ Read More
Given a string S containing lowercase latin letters. A character c is called K-amazing if every substring of S with length atleast K contains thisâ€¦ Read More
Given an array of N integers where array elements form a strictly decreasing and increasing sequence. The task is to find the smallest number inâ€¦ Read More
Given an array arr[] of N integers and number of queries Q. The task is to answer three types of queries. Update [l, r] â€“â€¦ Read More