# Category Archives: Greedy

Given the array X[],   the task is to return the maximum suffix sub-array length of the same elements for each distinct element and the… Read More
Given an array X[] of length N. In each operation, the following task is performed: Decrement any value by 1. Replace any pair with their… Read More
Given an array arr[] of length N. Find a positive integer K such that the difference between any pair of array elements is not a… Read More
Given an integer N, denoting the size of a circular array containing non-zero elements and an array arr[] of size M having the indices of… Read More
Given a matrix mat[][] of size N * N, where mat[i][j] represents the time taken to reach from ith city to jth city. Also, given… Read More
Given an array arr[], the task is to find the maximum sum possible such that any subarray of the indices from [l, r] i.e all… Read More
Given an array vals[] of size N, where each element represents the value of each node (0 ≤ index ≤ N-1) and an array Edges[]… Read More
Given an array arr[] with size N, the task is to find the minimum possible sum of distinct elements over all the prefixes of the… Read More
Given an array arr[] of size N that denotes the type of an element, and another time array time[] of size N where time[i] denotes… Read More
Given an integer, N, the task is to find the maximum LCM (Least Common Multiple) that can be obtained from four numbers less than or… Read More
Given an integer N(N doesn’t contain zero at any index) along with X(1 ≤ X ≤ 9), the task is to find the minimum possible… Read More
Given two positive integer arrays X[] and Y[] of size N, Where all elements of X[] are distinct. Considering all the elements of X[] are… Read More
Given two arrays A[] and B[], the array C[] is formed by the XOR of ai and bi, i.e ci = ai^bi, the task is… Read More
Given two arrays arr[] and arr2[], and a value K, the task is to check whether the array arr[] can be made to all zeros… Read More
Given an Array A[] of size N with repeated elements and all array elements are positive, the task is to find the maximum sum by… Read More