# Category Archives: Competitive Programming

## Minimum matches the team needs to win to qualify

Given two integers X and Y where X denotes the number of points required to qualify and Y denotes the number of matches left. The… Read More »

## Minimum cost to make two strings same

Given four integers a, b, c, d and two strings S1 and S2 of equal length, which consist only of the characters ‘2’, ‘1’ and… Read More »

## Number of ways to select a node from each connected component

Given a graph with N nodes and M edges. The task is to find the number of ways to select a node from each connected… Read More »

## Pick points from array such that minimum distance is maximized

Given C magnets and an array arr[] representing N index positions where C ≤ N. The task is to place these magnets at these available… Read More »

## Two equal sum segment range queries

Given an array arr[] consisting of N positive integers, and some queries consisting of a range [L, R], the task is to find whether the… Read More »

## Perimeter of Convex hull for a given set of points

Given n 2-D points points[], the task is to find the perimeter of the convex hull for the set of points. A convex hull for… Read More »

## Sum of even values and update queries on an array

Given an array arr[] of integers and an array q[] of queries. For the ith query, index = q[i] and value = q[i]. The task… Read More »

## Number of connected components in a 2-D matrix of strings

Given a 2-D matrix mat[][] the task is count the number of connected components in the matrix. A connected component is formed by all equal… Read More »

## Count Numbers in Range with difference between Sum of digits at even and odd positions as Prime

Given a range [L, R]. The task is to count the numbers in the range having difference between the sum of digits at even position… Read More »

## Sum of bitwise AND of all submatrices

Given a NxN matrix, the task is to find the sum of bit-wise AND of all of its rectangular sub-matrices. Examples: Input : arr[][] =… Read More »

## Number of trailing zeroes in base B representation of N!

Given two positive integers B and N. The task is to find the number of trailing zeroes in b-ary (base B) representation of N! (factorial… Read More »

## Minimum number of given powers of 2 required to represent a number

Given an integer x and an array arr[] each element of which is a power of 2. The task is to find the minimum number… Read More »

## Count possible moves in the given direction in a grid

Given a grid N x M size and initial position (X, Y) and a series of K moves. Each move contains 2 integers Dx and… Read More »

## Convex Hull | Monotone chain algorithm

Given a set of points, the task is to find the covex hull of the given points. The convex hull is the smallest convex polygon… Read More »

## Minimum operations required to modify the array such that parity of adjacent elements is different

Given an array A[], the task is to find the minimum number of operations required to convert the array into B[] such that for every… Read More »