# Category Archives: Competitive Programming

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

## Reduce the array by deleting elements which are greater than all elements to its left

Given an array arr[] of N integers, the task is to delete the element from the given array if element to it’s left is smaller… Read More »

## Finding Median of unsorted Array in linear time using C++ STL

Given an unsorted array arr[] having N elements, the task is to find out the median of the array in linear time complexity. Examples: Input:… Read More »

## Average of Cubes of first N natural numbers

Given a positive integer N, the task is to find the average of cubes of first N natural numbers. Examples:   Input: N = 2 Output: 4.5 Explanation: For integer… Read More »

## Count of substrings of length K with exactly K distinct characters

Given a string str of lowercase alphabets and an integer K, the task is to count all substrings of length K which have exactly K… Read More »

## Longest subarray whose elements can be made equal by maximum K increments

Given an array arr[] of positive integers of size N and a positive integer K, the task is to find the maximum possible length of… Read More »

## Shortest path in a directed graph by Dijkstra’s algorithm

Given a directed graph and a source vertex in the graph, the task is to find the shortest distance and path from source to target… Read More »

## Merge Sort vs. Insertion Sort

Pre-requisite: Merge Sort, Insertion Sort Merge Sort: is an external algorithm and based on divide and conquer strategy. In this sorting: The elements are split… Read More »

## Split the string into minimum parts such that each part is in the another string

Given two strings A and B, the task is to split the string A into the minimum number of substrings such that each substring is… Read More »

## Inversion Count using Policy Based Data Structure

Pre-requisite: Policy based data structure Given an array arr[], the task is to find the number of inversions for each element of the array. Inversion… Read More »