Problem of 8 Neighbours of an element in a 2-D Matrix

Given a 2-D Matrix and an integer ‘K’, the task is to predict the matrix after ‘K’ iterations given as follows: An element 1 in… Read More »

Find three integers less than or equal to N such that their LCM is maximum

Given a number N(>=3). The task is to find the three integers (<=N) such that LCM of these three integers is maximum. Examples: Input: N… Read More »

Count number of triplets (a, b, c) such that a^2 + b^2 = c^2 and 1 <= a <= b <= c <= n

Given an integer N, the task is to count the number of triplets (a, b, c) such that a2 + b2 = c2 and 1… Read More »

Find a point that lies inside exactly K given squares

Given an integer K and an array arr each of whose element x represents a square with two of its vertices as (0, 0) and… Read More »

String which when repeated exactly K times gives a permutation of S

Given an integer K and a string str of lowercase English characters, the task is to find a string s such that when s is… Read More »

Maximum length substring with highest frequency in a string

Given a string. The task is to find the maximum occurred substring with a maximum length. These occurrences can overlap. Examples: Input: str = “abab”… Read More »

Sum of the digits of a number N written in all bases from 2 to N/2

Given an integer N, the task is to find the sum of the digits of the number N written in all the bases from 2… Read More »

Sum of elements in an array having prime frequency

Given an array arr, the task is to find the sum of the elements which have prime frequencies in the array. Note: 1 is neither… Read More »

Lexicographically Smallest Permutation of length N such that for exactly K indices, a[i] > a[i] + 1

Given two integers N and K, the task is to generate a permutation of N numbers (Every number from 1 to N occurs exactly once)… Read More »

Minimum elements to be added in a range so that count of elements is divisible by K

Given three integer K, L and R (range [L, R]), the task is to find the minimum number of elements the range must be extended… Read More »

Check if N can be represented as sum of integers chosen from set {A, B}

Given three integers N, A and B, the task is to find whether N can be represented as sum of A’s and B’s. Examples: Input:… Read More »

Check if N is divisible by a number which is composed of the digits from the set {A, B}

Given three integers N, A and B, the task is to find whether N is divisible by any number that contains only A and B… Read More »

Minimum number of increment/decrement operations such that array contains all elements from 1 to N

Given an array of N elements, the task is to convert it into a permutation (Each number from 1 to N occurs exactly once) by… Read More »

Lexicographically smallest substring with maximum occurrences containing a’s and b’s only

Given a string ( containing characters from ‘0’ to ‘9’) and two digits and . The task is to find the substring in the given… Read More »

Partiton N into M parts such that difference between Max and Min part is smallest

Given two integers N and M, partition N into M integers such that the difference between the maximum and minimum integer obtained by the partition… Read More »