Count of Distinct Substrings occurring consecutively in a given String
Given a string str, the task is to find the number of distinct substrings that are placed consecutively in the given string....
read more
Find the only element that appears b times
Given an array where every element occurs ‘a’ times, except one element which occurs b (a>b) times. Find the element that occurs b times....
read more
Minimize increments or decrements required to make sum and product of array elements non-zero
Given an array arr[] of N integers, the task is to count the minimum number of increment or decrement operations required on the array such that the sum and product of all the elements of the array arr[] are non-zero....
read more
Minimum swaps of same indexed elements required to obtain a Majority Element in one of the arrays
Given two arrays arr[] and brr[] of length N, the task is to find the minimum number of swaps of the same indexed elements required such an element occurs at least half of the indices in the array arr[], i.e. Majority element. If it is not possible to obtain such an arrangement, then print “-1”....
read more
Partition array into minimum number of equal length subsets consisting of a single distinct value
Given an array arr[] of size N, the task is to print the minimum count of equal length subsets the array can be partitioned into such that each subset contains only a single distinct element...
read more
Modify string by replacing all occurrences of given characters by specified replacing characters
Given a string S consisting of N lowercase alphabets and an array of pairs of characters P[][2], the task is to modify the given string S by replacing all occurrences of character P[i][0] with character P[i][1]....
read more
Bitwise XOR of elements having odd frequency
Given an array arr[] of N elements, the task is to find the XOR of the elements which appear an odd number of times in the array.Examples:...
read more
Anagram checking in Python using collections.Counter()
Write a function to check whether two given strings are anagram of each other or not. An anagram of a string is another string that contains same characters, only the order of characters can be different. For example, “abcd” and “dabc” are anagram of each other....
read more
Count of subarrays which contains a given number exactly K times
Given an array A[] of N elements consisting of values from 1 to N with duplicates, the task is to find the total number of subarrays that contain a given number num exactly K times....
read more
Maximize count of K unique elements that can be chosen from Array
Given an arrays arr[] of size N and an array of queries Q[] of size M, where Q[i] defines the count of unique elements that have to be chosen from the array arr[]. The task to find the maximum number of elements that can be picked for each query....
read more
Maximum frequency of any array element possible by at most K increments
Given an array arr[] of size N and an integer K, the task is to find the maximum possible frequency of any array element by at most K increments....
read more
Number of substrings having an equal number of lowercase and uppercase letters
Given string S consists of lowercase and uppercase letters, the task is to find the number of substrings having an equal number of lowercase and uppercase letters....
read more