# Category Archives: Competitive Programming

## Nearest prime number in the array of every array element

Given an integer array arr[] consisting of N integers, the task is to find the nearest Prime Number in the array for every element in… Read More »

## Length of race track based on the final distance between participants

Given three integers A, B and C, the task is to find the length of a race track if 3 racers are competing in a… Read More »

## Count of intersections of M line segments with N vertical lines in XY plane

Given x coordinates of N vertical lines (parallel to Y-axis) and M line segments extending from (x1, y1) to (x2, y2), the task is to… Read More »

## Count of ways to traverse a Matrix and return to origin in K steps

Given three integers N, M and K, where N and M are the dimensions of the matrix and K is the maximum possible steps, the… Read More »

## Sort an array by swapping elements of different type specified by another array

Given two arrays a[] and b[] which contains the integer elements and their respective types (either type 0 or type 1) respectively, the task is… Read More »

## Minimum jumps required to group all 1s together in a given Binary string

Given a binary string S, the task is to count the minimum number of jumps required to group all 1’s together. Examples: Input: S =… Read More »

## Subsequence with maximum pairwise absolute difference and minimum size

Given an array arr[] of N integers, the task is to print the subsequence from the given array with the maximum pairwise absolute difference of… Read More »

## Count of all possible bitonic subarrays

Given an array arr[] consisting of N integers, the task is to count all the subarrays which are Bitonic in nature. A bitonic subarray is… Read More »

## Hexadecimal equivalents in Binary Valued Graph

Given a binary valued undirected graph with V vertices and E edges, the task is to find the hexadecimal equivalents of all the connected components… Read More »

## Longest subsequence consisting of alternate vowels and consonants

Given a non-empty string S, the task is to print the longest subsequence from the string S which contains alternating vowels and consonants. Note: If… Read More »

## Check if a subsequence of length K with odd sum exists

Given an array arr[] of integers, the task is to check if it is possible to obtain a subsequence of K elements from the array… Read More »

## Find the Nth row in Pascal’s Triangle

Given a non-negative integer N, the task is to find the Nth row of Pascal’s Triangle. Note: The row index starts from 0. Pascal’s Triangle:… Read More »

## Path traversed using exactly M coins in K jumps

Given three integers N, K and M representing the Number of boxes (aligned horizontally from 1 to N), total numbers of allowed jumps and total… Read More »

## Count of K-size substrings having palindromic permutations

Given a string str consist of only lowercase alphabets and an integer K, the task is to count the number of substrings of size K… Read More »

## Partition a set into two subsets such that difference between max of one and min of other is minimized

Given an array arr[] of N integers, the task is to split the array into two subsets such that the absolute difference between the maximum… Read More »