Given an even integer N, the task is to construct a string such that the total number of distinct substrings of that string that are… Read More

# Category Archives: Greedy

Given a string S consisting of only lowercase letters, the task is to find the lexicographically largest string that can be obtained by removing K… Read More

Given an integer N and array arr[] consisting of 3 * N integers, the task is to find the maximum difference between first half and… Read More

Given a Unix Timestamp T (in seconds) for a given point in time, the task is to convert it to human-readable format (DD/MM/YYYY HH:MM:SS) Example:… Read More

Given a rectangle of dimensions L and W. The task is to find the maximum area of a rectangle that can be circumscribed about a… Read More

Given two arrays A[] and B[], each consisting of N integers, containing the speeds of two trains travelling in the same direction, at each time… Read More

Given a Tree consisting of N nodes having values in the range [0, N – 1] and (N – 1) edges, and two nodes X… Read More

Given an integer N, the task is to find the largest number M, where (M < N), such that N(XOR)M is equal to N(OR)M i.e.… Read More

Given an integer N, the task is to count the minimum steps required to reduce the value of N to 0 by performing the following… Read More

Given an array A[] consisting of N integers, the task is to find the maximum subset-sum possible if the sum of all the elements is… Read More

Given two arrays A[] and B[] both of size N consisting of distinct elements, the task is to find the minimum cost to swap two… Read More

Given an integer array arr[] of size N, the task is to construct an array consisting of N+1 strings of length N such that arr[i]… Read More

Given an array A[], consisting of N elements, the task is to find the minimum number of swaps required such that array elements swapped to… Read More

Given an array arr[] consisting of N positive integers, the task is to find any permutation of given array such that the product of adjacent… Read More

Given an array arr[] of N integers, where N > 2, the task is to find the second largest product pair from the given array.… Read More