This is one of the most essential operation that programmer quite often comes in terms with. Be it development or competitive programming, this utility is quite essential to master as it helps to perform many tasks that involve this task to be its subtask. Lets discuss various approaches to achieve this operation. Method #1 : Naive method As the brute force method, we just count all the elements and then just return the element whole count remains the maximum at the end. This is the basic method that one could think of executing when faced with this issue....
Given an array arr[] of N integers, the task is to find the count of unordered index pairs (i, j) such that i != j and 0 <=i < j < N and either arr[i] is divisible by arr[j] or arr[j] is divisible by arr[i]....
Given an array arr[] and an integer K, the task is to count subarrays of size K in which every element appears an even number of times in the subarray....
Given an array arr[] of size N, the task is to find the sum of the floor value of (arr[i] / arr[j]) for all pairs of indices (i, j)....
Given a list of strings Str, find the largest string among all. The largest string is the string with the largest number of unique characters....
Given two strings X and Y, we need to convert string X into an anagram of string Y with minimum replacements. If we have multiple ways of achieving the target, we go for the lexicographically smaller string where the length of each string...
Given a string S consisting of characters from ‘a’ to ‘z’. The task is to find the length of the largest substring of S which contains a character whose frequency in the sub-string is greater than or equal to half of the length of the substring.Note: For odd-length substring, to calculate half-length consider integer division. For example, half of 11 is 5....
Given a binary array A[] of size N, the task is to check whether the array can be converted into a palindrome by flipping two bits in each operation....
Given a string, sort it in descending order....
Given an array arr[] consisting of N integers and an integer K, the task is to find the maximum number of unique elements possible by increasing any array element by K only once....
Given an array arr[] consisting of N positive integers, the task is to find an index from the array having count of prime numbers present on its left and right are equal....
Given a string S consisting of lowercase English letters and an integer K, the task is to find, for each distinct character in S, the largest index having this character exactly K times. If no such characters exist, print -1. Print the result in a lexicographical ordering.Note: Consider 0-based indexing in S....