# Category Archives: Algorithms

## Check if a string can be split into two strings with same number of K-frequent characters

Given a string S and an integer K, the task is to check if it is possible to distribute these characters into two strings such… Read More »

## Sort a Bitonic Array

Given a bitonic array arr[] the task is to sort the given bitonic array. A Bitonic Sequence is a sequence of numbers that is first… Read More »

QuickSort is a popular sorting technique based on divide and conquer algorithm. In this technique, an element is chosen as a pivot and the array… Read More »

## Sort Array such that smallest is at 0th index and next smallest it at last index and so on

Given an array, arr[] of N integers, the task is to rearrange the array elements such that the smallest element is at the 0th position,… Read More »

## Split array into K subsets to maximize their sum of maximums and minimums

Given an integer K and an array A[ ] whose length is multiple of K, the task is to split the elements of the given… Read More »

## Count of ways to generate a Matrix with product of each row and column as 1 or -1

Given two integers N and M, the task is to find the numbers of ways to form a matrix of size N * M consisting… Read More »

## Count of substrings having all distinct characters

Given a string str consisting of lowercase alphabets, the task is to find the number of possible substrings (not necessarily distinct) that consists of distinct… Read More »

## Min steps to empty an Array by removing a pair each time with sum at most K

Given an array arr[] and a target value K. The task is to find the minimum number of steps required to take all elements from… Read More »

## Longest subarray of non-empty cells after removal of at most a single empty cell

Given a binary array arr[], the task is to find the longest subarray of non-empty cells after the removal of at most 1 empty cell.… Read More »

## Find largest factor of N such that N/F is less than K

Given two numbers N and K, the task is to find the minimum value X such that N < X*K. Examples: Input: N = 8,… Read More »

## Construct the smallest possible Array with given Sum and XOR

Given two positive integers S and X which represents the sum and Bitwise XOR of all the elements of an array arr[]. The task is… Read More »

## Count of N-digit numbers with absolute difference of adjacent digits not exceeding K

Given two integers N and K, the task is to find the count of N-digit numbers such that the absolute difference of adjacent digits in… Read More »

## Calculate weight of parenthesis based on the given conditions

Given a valid parenthesis string S, the task is to find the weight of parenthesis based on the following conditions: Weight of “( )” is… Read More »

## Select K elements from an array whose maximum value is minimized

Given an array arr[] having N integers and an integer K, the task is to select K elements from the given array such that sum… Read More »

## Sorting boundary elements of a matrix

Given a matrix mat[][] of size M*N, the task is to sort only the border elements of the matrix in the clockwise direction and print… Read More »