# Category Archives: Competitive Programming

## Queries for the count of even digit sum elements in the given range using Segment Tree.

Given an array arr[] of N elements, the task is to answer Q queries each having two integers L and R. For each query, the… Read More »

## Find sum of xor of all unordered triplets of the array

Given an array A, consisting of N non-negative integers, find the sum of xor of all unordered triplets of the array. For unordered triplets, the… Read More »

## Move all zeroes to end of array using Two-Pointers

Given an array of random numbers, Push all the zero’s of the given array to the end of the array. For example, if the given… Read More »

## Count of numbers in a range that does not contain the digit M and which is divisible by M.

Given three integers the lower range L ,the upper range U and a digit M. The task is to count all the numbers between L… Read More »

## Program to find if two numbers and their AM and HM are present in an array using STL

Given an array of Number and two values A and B, The task is to check the following Conditions: If two numbers are present in… Read More »

## Turn off the rightmost set bit | Set 2

Given a Number N. The task is to unset the rightmost set bit of N. Examples: Input: N = 5 Output: 4 Explanation: 101(5) ->… Read More »

## Insert minimum parantheses to make string balanced

Given a string of digits S. The task is to insert a minimum number of opening and closing parentheses into the string S such that… Read More »

## Find number of segments covering each point in an given array

Given segments and some points, for each point find the number of segments covering that point. A segment (l, r) covers a point x if… Read More »

## Range Queries to find the Element having Maximum Digit Sum

Given an array Arr of N integers and Q queries, each query having a range from L to R. Find the element having maximum digit… Read More »

## Range Update Queries to XOR with 1 in a Binary Array.

Given a binary array arr[] of size N. The task is to answer Q queries which can be of any one type from below: Type… Read More »

## Count triplet of indices (i, j, k) such that XOR of elements between [i, j) equals [j, k]

Given an array of integers Arr. The task is to count the number of triplets (i, j, k) such that Ai ^ Ai+1 ^ Ai+2… Read More »

## Maximum sum such that exactly half of the elements are selected and no two adjacent

Given an array A containing N integers. Find the maximum sum possible such that exactly floor(N/2) elements are selected and no two selected elements are… Read More »

## Check if an array has some palindromic subsequence of length at least 3

Given is an array Arr of integers. The task is to determine if the array has any subsequence of at least length 3 that is… Read More »

## Sum of N-terms of geometric progression for larger values of N | Set 2 (Using recursion)

A Geometric series is a series with a constant ratio between successive terms. The first term of the series is denoted by a and the… Read More »

## Queries for elements having values within the range A to B in the given index range using Segment Tree

Given an array arr[] of N elements and two integers A to B, the task is to answer Q queries each having two integers L… Read More »