Category Archives: Algorithms

Lexicographic smallest permutation of a String containing the second String as a Substring

Given two strings str1 and str2, the task is to find the lexicographic smallest permutation of str1 that contains str2 as a substring.Note: Assume that… Read More »

Count of substrings of a Binary string containing only 1s

Given a binary string of length N, we need to find out how many sub-strings of this string contains only 1s. Examples:  Input: S =… Read More »

Product of proper divisors of a number for Q queries

Given an integer N, the task is to find the product of proper divisors of the number modulo 109 + 7 for Q queries. Examples:… Read More »

Highest power of 2 that divides the LCM of first N Natural numbers.

Given a number N, the task is to find the largest power of 2 that divides LCM of first N Natural numbers. Examples: Input: N… Read More »

Check if number can be made prime by deleting a single digit

Given an integer N, the task is to check if it is possible to make N prime by deleting any single digit from N. Examples:… Read More »

Check if a number has an odd count of odd divisors and even count of even divisors

Given an integer N, the task is to check if N has an odd number of odd divisors and even number of even divisors. Examples:… Read More »

Count of distinct permutations of every possible length of given string

Given a string S, the task is to count the distinct permutations of every possible length of the given string. Note: Repetition of characters is… Read More »

Find the area of rhombus from given Angle and Side length

Given two integers A and X, denoting the length of a side of a rhombus and an angle respectively, the task is to find the… Read More »

Restore original String from given Encrypted String by the given operations

Given a string str and a positive integer N, the task is to reverse N characters and skip N characters until the end of the… Read More »

The Google online challenge 2020 for summer internships 2021 was held on August 16. It was a 60-minute online test having 2 questions to code.… Read More »

You are working in Samara, Russia for a few days. Each day has a new pay per unit of work and a new cost per… Read More »

Maximize minimum distance between repetitions from any permutation of the given Array

Given an array arr[], consisting of N positive integers in the range [1, N], the task is to find the largest minimum distance between any… Read More »

Minimum Subarray flips required to convert all elements of a Binary Array to K

Given a binary array arr[] consisting of N integers, the task is to calculate the minimum number of operations of the following type needed to… Read More »

Calculate the Square of Euclidean Distance Traveled based on given conditions

Given an array commands[], consisting of signed integers denoting distance and direction to be travelled along with the coordinates, and array obstacles[] denoting the coordinates… Read More »

Check if sum Y can be obtained from the Array by the given operations

Given an array of integers arr[] and two integers X and Y, the task is to check if it is possible to obtain a sequence… Read More »