Arnab Chakraborty has Published 3734 Articles

Program to find sum of absolute differences in a sorted array in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 06-Oct-2021 10:55:36

574 Views

Suppose we have an array nums and that is sorted in non-decreasing order. We have to make an array called result with the same length as nums such that result[i] is the summation of absolute differences between nums[i] and all the other elements in the array.So, if the input is ... Read More

Program to find equal sum arrays with minimum number of operations in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 06-Oct-2021 10:52:18

672 Views

Suppose we have two arrays of called nums1 and nums2. The values in the arrays are between 1 and 6(inclusive). In one operation, we can update any value in any of the arrays to any value between 1 and 6. We have to find the minimum number of operations needed ... Read More

Program to find concatenation of consecutive binary numbers in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 06-Oct-2021 10:50:24

592 Views

Suppose we have a number n, we have to find the decimal value of the binary string by concatenating the binary representations of 1 to n one by one in order, if the answer is too large then return answer modulo 10^9 + 7.So, if the input is like n ... Read More

Program to find closest dessert cost in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 06-Oct-2021 10:47:52

247 Views

Suppose we have two arrays called baseCosts with n items from them we can select base and toppingCosts with m items from them we can select toppings and also have a target value. We have to follow these rules to make dessert.There must be exactly one base.We can add one ... Read More

Program to find max number of K-sum pairs in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 06-Oct-2021 10:45:25

620 Views

Suppose we have an array called nums and another value k. In one operation, we can select two elements from nums whose sum is equals to k and remove them from the array. We have to find the maximum number of operations we can perform on the array.So, if the ... Read More

Program to check whether string Is transformable with substring sort operations in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 06-Oct-2021 09:36:07

187 Views

Suppose we have two numeric strings s and t, we want to transform from string s to t using the following operation any number of times: 1. Select a non-empty substring in s and sort it inplace so the characters are in ascending order. We have to check whether it ... Read More

Program to find out if the graph is traversable by everybody in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 06-Oct-2021 09:32:25

215 Views

Suppose, we are given a graph that contains n vertices numbered 0 to n - 1. The graph is undirected and each edge has a weight. The graph can have three types of weights and each weight signifies a particular task. There are two people that can traverse the graph, ... Read More

Program to detect cycles in 2D grid in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 06-Oct-2021 09:27:24

324 Views

Suppose we have one 2D array of characters called grid of size m x n. We have to check whether we can detect a cycle inside it or not. Here a cycle is a path of length 4 or more in the grid that starts and ends at the same ... Read More

Program to find minimum number of days to eat N oranges in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 06-Oct-2021 09:13:33

329 Views

Suppose we have a number n. So consider there are n oranges in the kitchen and we eat some of these oranges every day maintaining these rules: 1. Eat single orange. 2. If n is even, then eat n/2 oranges. 3. If n is divisible by 3 can eat 2*(n/3) ... Read More

Program to find minimum cost to cut a stick in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 06-Oct-2021 09:09:38

834 Views

Suppose we have a value n and an array called cuts. Consider there is a wooden stick of length n units. The stick is labelled from 0 to n. Here cuts[i] represents a position where we can cut. We should perform the cuts in order, but we can change the ... Read More

Advertisements