Arnab Chakraborty has Published 4452 Articles

Program to find minimum number of swaps needed to arrange all pair of socks together in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 25-Dec-2020 05:46:28

123 Views

Suppose we have a list of numbers called row and this is representing socks lying in a row. They are not sorted, but we want to rearrange them so that each pair of socks are side by side like (0, 1), (2, 3), (4, 5), and so on. We have ... Read More

Program to find sum of medians of all odd length sublists in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 25-Dec-2020 05:44:53

183 Views

Suppose we have a list of numbers called nums, we have to find the sum of the medians of every odd−length sublist of the given list.So, if the input is like nums = [2, 4, 6, 3], then the output will be 23, as the odd−length sublists are − [2], ... Read More

Program to Find the Shortest Distance Between Two Points in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 23-Dec-2020 07:04:51

1K+ Views

Suppose we have a list of coordinates where each element is of the form [x, y], representing Euclidean coordinates. We have to find the smallest squared distance (x1 - x2) 2 + (y1 - y2) 2 between any two provided coordinates.So, if the input is like coordinates = {{1, 2}, ... Read More

Program to Find Out the Maximum Final Power of a List in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 23-Dec-2020 07:03:03

155 Views

Suppose, we have a list and the power of a list is defined by the sum of (index + 1) * value_at_index over all indices. Alternatively, we can represent it like this −$$\displaystyle\sum\limits_{i=0}^{n-1} (i+1)\times list[i]$$Now, we have a list nums that has N positive integers. We can select any singular ... Read More

Program to Find Out the Minimum Cost Possible from Weighted Graph in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 23-Dec-2020 07:00:57

615 Views

Suppose we have a 2D list of integers called edges which are a representation of an undirected graph. Every row in the input represents an edge [u, v, w] meaning nodes u and v are connected and the edge has the weight w. The graph consists of n nodes from ... Read More

Program to Find Out the Number of Corrections to be Done to Fix an Equation in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 23-Dec-2020 06:58:19

131 Views

Suppose we have a string s which represents an equation of the form x+y=z. We have to find the minimum number of digits that we need to add into s so the equation becomes true.So, if the input is like s = '2+6=7', then the output will be 2.We can ... Read More

Program to Find Out the Points Achievable in a Contest in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 23-Dec-2020 06:55:53

121 Views

Suppose we are in a programming contest where there are multiple problems but the contest ends when we solve one problem. Now if we have two lists of numbers of the same length called points, and chances. To explain it, here for the ith problem, we have a chances[i] percent ... Read More

Program to Find Out the Minimum Cost to Purchase All in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 23-Dec-2020 06:53:54

256 Views

Suppose, we have N items, which are marked as 0, 1, 2, …, N-1. Then, we are given a 2D list of size S called sets. Here, we can purchase the i-th set for the price sets[i, 2], and we receive every item between sets[i, 0] to sets[i, 1]. Also, ... Read More

Program to Find Out the Cost after Finding k Unique Subsequences From a Given String in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 23-Dec-2020 06:51:32

119 Views

Suppose, we have a string s and another value k. We have to select some subsequences of s, so that we can get k unique subsequences. Here, the cost of selecting a subsequence equals the length of (s) - length of (subsequence). So, we have to find the lowest total ... Read More

Program to Find Out the Strings of the Same Size in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 23-Dec-2020 06:49:48

108 Views

Suppose, we have a string 'i' consisting of lowercase letters and another integer 'j'. We have to find out how many strings there are that are equal to the size of 'i' and are lexicographically smaller or equal to 'i' and having no consecutive equal characters greater than 'j'.The answer ... Read More

Advertisements