# Category Archives: Competitive Programming

## Probability of A winning the match when individual probabilities of hitting the target given

Given four integers a, b, c and d. Player A & B try to score a penalty. Probability of A shooting the target is a… Read More »

## Maximum subarray sum by flipping signs of at most K array elements

Given an array arr[] of N integers and an integer K. The task is to find the maximum sub-array sum by flipping signs of at… Read More »

## Chessboard Pawn-Pawn game

There is a 8*8 chessboard and two chess players having a single pawn each. A player has to move his pawn in each turn, either… Read More »

## Missing even and odd elements from the given arrays

Given two integer arrays even[] and odd[] which contains consecutive even and odd elements respectively with one element missing from each of the arrays. The… Read More »

## Pick maximum sum M elements such that contiguous repetitions do not exceed K

Given an array arr[] of distinct elements and two integers M and K, the task is to generate an array from the given array elements… Read More »

## 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 »