Minimum removals to make array sum odd

Given an array Arr[] of N integers. The task is to find minimum number of elements needed to be removed from the array, so that… Read More »

Minimum index i such that all the elements from index i to given index are equal

Given an array arr[] of integers and an integer pos, the task is to find the minimum index i such that all the elements from… Read More »

Minimum number of given operations required to convert a string to another string

Given two strings S and T of equal length. Both strings contain only the characters ‘0’ and ‘1’. The task is to find the minimum… Read More »

Minimum elements to be removed such that sum of adjacent elements is always odd

Given an array of N integers. The task is to eliminate the minimum number of elements such that in the resulting array the sum of… Read More »

Minimum number of operations on an array to make all elements 0

Given an array arr[] of N integers and an integer cost, the task is to calculate the cost of making all the elements of the… Read More »

Check if a binary string contains consecutive same or not

Given a binary string str consisting of characters ‘0’ and ‘1’. The task is to find whether the string is valid or not. A string… Read More »

Maximum subarray sum in array formed by repeating the given array k times

Given an integer k and an integer array arr[] of n elements, the task is to find the largest sub-array sum in the modified array… Read More »

Minimum replacements to make adjacent characters unequal in a ternary string

Given a string of ‘0’, ‘1’ and ‘2’. The task is to find the minimum number of replacements such that the adjacent characters are not… Read More »

Array element with minimum sum of absolute differences

Given an array arr[] of N integers, the task is to find an element x from the array such that |arr[0] – x| + |arr[1]… Read More »

Generate lexicographically smallest string of 0, 1 and 2 with adjacent swaps allowed

Given a string str containing only characters 0, 1 and 2, you can swap any two adjacent (consecutive) characters 0 and 1 or any two… Read More »

Length of the longest substring with consecutive characters

Given a string str of lowercase alphabets, the task is to find the length of the longest sub-string of characters in alphabetical order i.e. string… Read More »

Minimum moves to reach from i to j in a cyclic string

Given a cyclic string str and two integers i and j, the task is to count the minimum number of steps required to move from… Read More »

Maximum value of arr[i] % arr[j] for a given array

Given an array arr[], the task is to find the maximum value of arr[i] % arr[j] for all possible pairs. Examples: Input: arr[] = {… Read More »

Count number of pairs (i, j) such that arr[i] * arr[j] > arr[i] + arr[j]

Given an array arr[] of non-negative integers, the task is to count pairs of indices (i, j such that arr[i] * arr[j] > arr[i] +… Read More »

Number of ways to remove a sub-string from S such that all remaining characters are same

Given a string str consisting only of lowercase English alphabets, the task is to count the number of ways to remove exactly one sub-string from… Read More »