# Category Archives: Competitive Programming

## Represent N as sum of K odd numbers with repetitions allowed

Given two integers N and K, the task is to represent N as sum of K odd numbers. If it is not possible to create… Read More »

## Longest Mountain Subarray

Given an array arr[] with N elements, the task is to find out the longest sub-array which has the shape of a mountain. A mountain… Read More »

## Array Range Queries to find the Maximum Armstrong number with updates

Given an array arr[] of N integers, the task is to perform the following two queries:  maximum(start, end): Print the maximum Armstrong number of elements… Read More »

## Range sum queries for anticlockwise rotations of Array by K indices

Given an array arr consisting of N elements and Q queries of the following two types: 1 K: For this type of query, the array… Read More »

## Print updated levels of each node of a Complete Binary Tree based on difference in weights of subtrees

Given a complete binary tree with N levels numbered [0, (N – 1 )] from root to the lowest level in decreasing order and having… Read More »

## Array range queries to find the number of perfect square elements with updates

Given an array arr[] of N integers, the task is to perform the following two queries:  query(start, end): Print the number of perfect square numbers… Read More »

## Basic Algorithm Techniques Not Taught in Academics

We generally study most of the algorithmic techniques in academics like Searching, Sorting, Dynamic Programming, Greedy Algorithms, Divide and Conquer, Backtracking, etc. But below techniques… Read More »

## Split a number as sum of K numbers which are not divisible by K

Given two numbers N and K, the task is to split this number into K positive integers such that their sum is equal to N… Read More »

## Count of perfect squares of given length

Given an integer N, the task is to find the number of perfect squares of length N. Examples: Input: N = 1 Output: 3 Explanation:… Read More »

## Maximum splits in binary string such that each substring is divisible by given odd number

Given a binary string str, the task is to calculate the maximum possible splits possible to make each substring divisible by a given odd number… Read More »

## Represent N as sum of K even numbers

Given two integers N and K, the task is to represent N as sum of K even number. If it is not possible to represent… Read More »

## Maximum of all subarrays of size K using Segment Tree

Given an array arr[] and an integer K, the task is to find the maximum for each and every contiguous subarray of size K. Examples:… Read More »

## Maximum XOR path of a Binary Tree

Given a Binary Tree, the task is to find the maximum of all the XOR value of all the nodes in the path from the… Read More »

## Range Queries to count the number of even parity values with updates

Given an array arr[] of N integers, the task is to perform the following two queries: query(L, R): Print the number of Even Parity numbers… Read More »

## Query to find the maximum and minimum weight between two nodes in the given tree using LCA.

Given a tree, and the weights of all the node. Each query contains two integers u and v, the task is to find the minimum… Read More »