Arnab Chakraborty has Published 4452 Articles

Program to reverse a linked list in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 20-Oct-2020 10:51:14

412 Views

Suppose we have a linked list, we have to reverse it. So if the list is like 2 -> 4 -> 6 -> 8, then the new reversed list will be 8 -> 6 -> 4 -> 2.To solve this, we will follow this approach −Define one procedure to perform ... Read More

Program to find string after removing consecutive duplicate characters in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 20-Oct-2020 10:48:27

318 Views

Suppose we have a string s, we repeatedly delete the first consecutive duplicate characters. We have to find the final string.So, if the input is like s = "xyyyxxz", then the output will be "z", as "yyy" are the first consecutive duplicate characters which will be deleted. So we have ... Read More

Program to count minimum invalid parenthesis to be removed to make string correct in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 20-Oct-2020 10:45:21

358 Views

Suppose we have a string of parentheses; we have to write a function to compute the minimum number of parentheses to be removed to make the string correct (each open parenthesis is eventually closed).So, if the input is like "(()))(", then the output will be 2, as the correct string ... Read More

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

89 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

377 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

166 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

241 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

94 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

12K+ 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

Advertisements