# Tag Archives: frequency-counting

## Rearrange an array such that product of every two consecutive elements is a multiple of 4

Given an array arr[] of size N, the task is to rearrange the array elements such that for every index i(1 <= i <= N… Read More »

## 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 »

## 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 »

## 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 »

## Count of ways to select K consecutive empty cells from a given Matrix

Given a binary matrix V[][] of dimensions N * M, wherein each cell is either empty or blocked marked by a 0 and 1 respectively,… Read More »

## Largest number made up of X and Y with count of X divisible by Y and of Y by X

Given three integers X, Y and N, the task is to find the largest number possible of length N consisting only of X and Y… Read More »

## Smallest number to be added in first Array modulo M to make frequencies of both Arrays equal

Given two arrays A[] and B[] consisting of N positive integers and a integer M, the task is to find the minimum value of X… Read More »

## Count of ways to split given string into two non-empty palindromes

Given a string S, the task is to find the number of ways to split the given string S into two non-empty palindromic strings. Examples:… Read More »

## Generate an Array such with elements maximized through swapping bits

Given an array arr[], the task is to generate a modified array such that all its elements are maximized by swapping of bits. Examples: Input:… Read More »

## Most frequent element in Array after replacing given index by K for Q queries

Given an array arr[] of size N, and Q queries of the form {i, k} for which, the task is to print the most frequent… Read More »

## Largest subarray with frequency of all elements same

Given an array arr[] of N integers, the task is to find the size of largest subarray with frequency of all elements same. Examples: Input:… Read More »

## Find first non-repeating character in a given string using Linked List

Given a string str of length L, the task is to find the first occurrence of a non-repeating character in the string.Examples:  Input: str =… Read More »

## Count of elements which cannot form any pair whose sum is power of 2

Given an array arr[] of length N, the task is to print the number of array elements which cannot form a pair with any other… Read More »

## Array sum after replacing all occurrences of X by Y for Q queries

Given an integer array arr[] and Q queries, the task is to find the sum of the array for each query of the following type:… Read More »

## Count of subtrees from an N-ary tree consisting of single colored nodes

Given a N-ary tree consisting of N nodes and a matrix edges[][] consisting of N – 1 edges of the form (X, Y) denoting the… Read More »