Skip to content

Category Archives: Greedy

Given an integer K denoting the fuel tank capacity of a car running at the cost of 1 liter / mtr on a straight path… Read More
Given an array A[] consisting of permutation of first N natural numbers, the task is to find the minimum number of operations required to modify… Read More
-Given two positive integers N and X, the task is to count the occurrences of the given integer X in an N-length square matrix generated… Read More
Given two arrays A[] and B[] consisting of N integers, the task is to minimize the total cost of incrementing or decrementing array elements by… Read More
Given two arrays arr[] and brr[] consisting of N and M positive integers respectively, the task is to find all the elements from the array… Read More
Given two positive integers N and X, the task is to count the occurrences of the given integer X in an N-length square matrix generated… Read More
Given an array arr[] of size N, the task is to convert every array element to 0 by applying the following operations exactly three times:… Read More
Given two arrays A[] and B[] consisting of N and M integers respectively, the task is to count pairs (A[i], B[j]) such that the product… Read More
Given an array arr[] of size N, consisting of binary values, the task is to find the longest non-empty subarray consisting only of 1s after… Read More
Given an array arr[] consisting of N integers and an integer X, the task is to find the minimum cost required to make all array… Read More
Given an array, arr[] consisting of N integers, the task is to minimize the number of increments of array elements required to make all differences… Read More
Given a string S of length N consisting of 1, 0, and X, the task is to print the character (‘1’ or ‘0’) with the… Read More
Given an array arr[] consisting of N positive integers, the task is to find the minimum number of increments required to make the array arr[]… Read More
Given an array arr[] consisting of N integers and an integer K, the task is to reduce K to 0 by removing an array element… Read More