# Category Archives: Competitive Programming

## Queries to check if any non-repeating element exists within range [L, R] of an Array

Given an array arr[] consisting of integers and queries Q of the form (L, R), the task is to check whether any non-repeating element is… Read More »

## Minimum number of squares whose sum equals to a given number N | Set-3

Pre-requisite: Lagrange’s Four-Square Theorem, Legendre’s Three-Square Theorem A number can always be represented as a sum of squares of other numbers. Note that 1 is… Read More »

## Count subarrays having sum of elements at even and odd positions equal

Given an array arr[] of integers, the task is to find the total count of subarrays such that the sum of elements at even position… Read More »

## Find Second largest element in an array | Set 2

Given an array arr[] consisting of N integers, the task is to find the second largest element in the given array using N+log2(N) – 2… Read More »

## Find any simple cycle in an undirected unweighted Graph

Given an un-directed and unweighted connected graph, find a simple cycle in that graph (if it exists). Simple Cycle: A simple cycle is a cycle… Read More »

## Minimum cost to empty Array where cost of removing an element is 2^(removed_count) * arr[i]

Given an array arr[], the task is to find the minimum cost to remove all elements from the array where cost of removing an element… Read More »

## String hashing using Polynomial rolling hash function

What is String-Hashing?  String hashing is the way to convert a string into an integer known as a hash of that string.An ideal hashing is… Read More »

## C++ Program for the Fractional Knapsack Problem

Pre-requisite: Fractional Knapsack Problem Given two arrays weight[] and profit[] the weights and profit of N items, we need to put these items in a… Read More »

## Minimum number of distinct powers of 2 required to express a given binary number

Given a binary string S, the task is to find the minimum number of Powers of 2 required to express a S.Examples:  Input: S =… Read More »

## Philaland Coin | TCS Mockvita 2020

Problem Description The problem solvers have found a new Island for coding and named it as Philaland. These smart people were given a task to… Read More »

## Collision Course | TCS MockVita 2020

Problem Description On a busy road, multiple cars are passing by. A simulation is run to see what happens if brakes fail for all cars… Read More »

## Find the value of P and modular inverse of Q modulo 998244353

Given two integer P and Q, the task is to find the value of P and modular inverse of Q modulo 998244353. That is  Note:… Read More »

## Find two numbers with given sum and maximum possible LCM

Given an integer X, the task is to find two integers A and B such that sum of these two numbers is X and the… Read More »

## Check if the given array is same as its inverse permutation

Given an array arr[] consisting of integers in the range [1, N], the task is to determine whether the Inverse Permutation of the given array… Read More »

## Tips for testing code in Compeititive programming

Testing Coding problems can sometimes become hectic. Here are some tips to use while testing Algorithmic Programming Problems. There are generally four major categories of… Read More »