# Category Archives: Algorithms

Given two integers N and D, the task is to find the closest number to N with the sum of digits equal to D. Examples:… Read More
Given an array arr[] of size N, the task is to find the minimum number of operations required to reduce all three elements of the… Read More
Given an array arr[] of length N and an integer M, the task is to determine if a strictly increasing sequence can be formed by… Read More
Given an array A[] of size N, find the permutation of array A such that the array B[] which is formed by taking the GCD… Read More
Given two integers M and N the task is to construct a binary palindromic string consisting of M occurrences of 0s and N occurrences of… Read More
Given an N×N matrix mat[][] and an integer K, the task is to search K in mat[][] and if found return its indices. Examples: Input:… Read More
Given two arrays of strings A[] and B[] containing only small case letters, the task is to count the number of strings in A[] such… Read More
Given Q queries in the form of a 2D array arr[][] in which every row consists of two numbers L and R which denotes a… Read More
Given an array A[] of N  integers, the task is to calculate the total number of pairs of indices (i, j) satisfying the following conditions… Read More
Given an array of non-negative integers arr[] and an integer K, the task is to minimize the product of array elements by performing at K… Read More
Given a string S of size M consisting of only zeroes (and hence representing the integer 0). Also, given an array A[] of size N… Read More
Given an array arr[] of N integers such that no element is 0 in that array, the task is to find the minimum number of… Read More
Given an array A[] of N integers, the task is to find the number of pairs of indices (1 ≤ i, j ≤ N) in… Read More
Given a string S that consists of only alphanumeric characters and dashes. The string is separated into N + 1 groups by N dashes. Also… Read More
Given two arrays A[] and B[] of the same length N. the task is to find a pair (X, Y) for two numbers Ai (number… Read More