Arnab Chakraborty has Published 4452 Articles

Moving Stones Until Consecutive II in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 13-Nov-2020 12:05:38

160 Views

Suppose we are considering an infinite number line, here the position of the i−th stone is given by array stones and stones[i] is indicating ith stone position. A stone is an endpoint stone if it has the smallest or largest position. Now in each turn, we pick up an endpoint ... Read More

Maximum Sum of Two Non-Overlapping Subarrays in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 13-Nov-2020 11:45:44

166 Views

Suppose we have an array A of integers; we have to find the maximum sum of elements in two non−overlapping subarrays. The lengths of these subarrays are L and M.So more precisely we can say that, we have to find the largest V for whichV = (A[i] + A[i+1] + ... Read More

Program to find airports in correct order in Python?

Arnab Chakraborty

Arnab Chakraborty

Updated on 10-Nov-2020 09:37:21

287 Views

Suppose we have a list of flights as [origin, destination] pairs. The list is shuffled; we have to find all the airports that were visited in the correct order. If there are more than one valid itinerary, return lexicographically smallest ones first.So, if the input is like flights = [["Mumbai", ... Read More

Program to check whether we can make k palindromes from given string characters or not in Python?

Arnab Chakraborty

Arnab Chakraborty

Updated on 10-Nov-2020 09:34:02

133 Views

Suppose we have a string s and another number k, we have to check whether we can create k palindromes using all characters in s or not.So, if the input is like s = "amledavmel" k = 2, then the output will be True, as we can make "level" and ... Read More

Program to find minimum number of Fibonacci numbers to add up to n in Python?

Arnab Chakraborty

Arnab Chakraborty

Updated on 10-Nov-2020 09:28:33

294 Views

Suppose we have a number n; we have to find the minimum number of Fibonacci numbers required to add up to n.So, if the input is like n = 20, then the output will be 3, as We can use the Fibonacci numbers [2, 5, 13] to sum to 20.To ... Read More

Program to find trailing zeros in factorial of n in C++?

Arnab Chakraborty

Arnab Chakraborty

Updated on 10-Nov-2020 09:25:30

130 Views

Suppose we have a number n, we have to find the number of trailing zeros of n!.So, if the input is like n = 20, then the output will be 4, as 20! = 2432902008176640000To solve this, we will follow these stepsset count := 0for i := 5, (n/i) > ... Read More

Program to perform excel spreadsheet operation in Python?

Arnab Chakraborty

Arnab Chakraborty

Updated on 10-Nov-2020 09:22:23

266 Views

Suppose we have a 2D matrix representing an excel spreadsheet. We have to find the same matrix with all cells and formulas computed. An excel spreadsheet looks like belowB17035=A1+A2The columns are named as (A, B, C...) and rows are (1, 2, 3....) Each cell will either contain a value, a ... Read More

Program to count number of operations required to convert all values into same in Python?

Arnab Chakraborty

Arnab Chakraborty

Updated on 10-Nov-2020 09:18:22

140 Views

Given a list of integers nums, you can perform the following operation: pick the largest number in nums and turn it into the second largest number. Return the minimum number of operations required to make all integers the same in the list.So, if the input is like nums = [5, ... Read More

Program to check whether we can make group of two partitions with equal sum or not in Python?

Arnab Chakraborty

Arnab Chakraborty

Updated on 10-Nov-2020 09:16:24

184 Views

Suppose we have a list of numbers called nums, we have to check whether we can partition nums into two groups where the sum of the elements in both groups are same.So, if the input is like nums = [2, 3, 6, 5], then the output will be True, as ... Read More

Program to enclose pattern into bold tag in Python?

Arnab Chakraborty

Arnab Chakraborty

Updated on 10-Nov-2020 09:14:34

291 Views

Suppose we have a text and a list of strings called patterns, we have to define an embolden function where all substrings in text that match any string in the given patterns are wrapped in  and  tags. If any two patterns are adjacent or overlap, they should be merged into ... Read More

Advertisements