Arnab Chakraborty has Published 4293 Articles

Program to remove sublist to get same number of elements below and above k in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 20-Oct-2020 10:43:04

169 Views

Suppose we have a list of numbers called nums and another number k, we can remove any sublist at most once from the list. We have to find the length of the longest resulting list such that the amount of numbers strictly less than k and strictly larger than k ... Read More

Program to find minimum number of intervals to be removed to remove overlaps in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 20-Oct-2020 10:37:18

492 Views

Suppose we have a set of intervals; we have to find the minimum number of intervals that should be removed to make the rest of the intervals non-overlapping. So if the intervals are [[8, 10], [3, 5], [6, 9]], then the output will be 1, as we have to remove ... Read More

Program to remove duplicate entries in a linked list in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 20-Oct-2020 10:34:42

213 Views

Suppose we have a linked list of numbers, we have to remove those numbers which appear multiple times in the linked list (hold only one occurrence in the output), we also have to maintain the order of the appearance in the original linked list.So, if the input is like [2 ... Read More

Program to update elements in a given range in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 20-Oct-2020 10:31:20

338 Views

Suppose we have a list of numbers called nums and a list of operations. Here each operation has three fields [L, R, X], this indicated that we should increment by X all the elements from indices L to R (inclusive). We have to apply all operations and return the final ... Read More

Program to find how many total amount of rain we can catch in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 20-Oct-2020 07:45:17

138 Views

Suppose we have an array of n non-negative integers. These are representing a height where the width of each bar is 1, we have to compute how much water it is able to catch after raining. So the map will be like −Here we can see there are 8 blue ... Read More

Program to find maximum product of contiguous subarray in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 20-Oct-2020 07:43:33

1K+ Views

Suppose we have an array called nums, we have to find the product of elements of a contiguous subarray within an array (containing at least one number) which has the largest product. So if the array is [1, 9, 2, 0, 2, 5], the output will be 18, as contiguous ... Read More

Program to evaluate Postfix Notation in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 20-Oct-2020 07:41:51

14K+ Views

Suppose we have postfix expression and we have to evaluate the value. Postfix expression is also known as Reverse polish notation. Here we have to use the stack data structure to solve the postfix expressions.So if the expression is “21+3*”, then the answer will be 9.Let us see the steps ... Read More

Program to find maximum value we can get in knapsack problem by taking multiple copies in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 20-Oct-2020 07:39:39

602 Views

Suppose we have two lists of same length they are called weights and values, and we also have another value capacity. Here weights[i] and values[i] represent the weight and value of the ith item. If we can take at most capacity weights, and that we can take any number of ... Read More

Program to count number of perfect squares are added up to form a number in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 20-Oct-2020 07:37:58

117 Views

Suppose we have a positive number n, we have to find the least number of perfect square numbers whose sum is same as n. So if the number is 10, then the output is 2, as the numbers are 10 = 9 + 1.To solve this, we will follow these ... Read More

Program to count number of ways we can distribute coins to workers in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 20-Oct-2020 07:36:17

340 Views

Suppose we have two lists of positive numbers called coins and salaries. Here coins[i] indicates the value for coin i and salaries[j] indicates the least amount of salary required to pay for worker j. Now suppose we have one coin per type and we must give each worker exactly one ... Read More

Advertisements