Arnab Chakraborty has Published 4293 Articles

Program to find sum of two numbers which are less than the target in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 14-Oct-2021 10:29:01

724 Views

Suppose we have a list of numbers called nums and also have a target value, we have to find the sum of the largest pair of numbers in nums whose sum is at most (target-1).So, if the input is like nums = [8, 3, 4, 9, 2] target = 8, ... Read More

Program to create data structure to check pair sum is same as value in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 14-Oct-2021 10:24:49

116 Views

Suppose we want to make a data structure that has two methods −add(val) this adds the value val to the data structurefind(val) this checks whether there are two elements whose sum is val or notWe have to design this so that we can get the result on the fly. We ... Read More

Program to check typed string is for writing target string in stuck keyboard keys or not in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 14-Oct-2021 10:19:08

184 Views

Suppose we have two strings s and t. We want to form t, but there are some problems in the keyboard where some of characters stuck so they may be written 1 or more times. We have to check whether it's possible that typed s was meant to write t ... Read More

Program to check whether list is alternating increase and decrease or not in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 14-Oct-2021 10:14:55

806 Views

Suppose we have a list of numbers called nums. We have to check whether the list alternates starting from strictly increasing then strictly decreasing and then strictly increasing and so on. And also if the list is only strictly increasing, it will be valid.So, if the input is like nums ... Read More

Program to find squared elements list in sorted order in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 14-Oct-2021 10:11:57

687 Views

Suppose we have a list of numbers called nums, where elements are sorted in ascending order, we have to square the elements and return the result in sorted order.So, if the input is like nums = [-8, -3, 0, 5, 6], then the output will be [0, 9, 25, 36, ... Read More

Program to sort numbers based on 1 count in their binary representation in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 14-Oct-2021 10:08:39

5K+ Views

Suppose we have a lists of numbers in nums. We have to sort the list in ascending order by the number of 1s present in the binary representation for each number. If two numbers have same number of 1s, then arrange them based on their values.So, if the input is ... Read More

Program to find smallest pair sum where distance is not consecutive in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 14-Oct-2021 10:06:34

279 Views

Suppose we have a list of numbers called. Now let us consider any pair of indices (i, j) where i < j and j - i > 1. Then find the smallest pair sum.So, if the input is like nums = [3, 4, 2, 2, 4], then the output will ... Read More

Program to form smallest number where no two adjacent digits are same in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 14-Oct-2021 10:02:35

370 Views

Suppose we have a string s with four possible characters "1", "2", "3" and "?". We can place any one of "1", "2" and "3", in the place of "?". We have to find the smallest possible number that we can make such that no two adjacent digits are same.So, ... Read More

Program to find length of shortest sublist with maximum frequent element with same frequency in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 14-Oct-2021 09:56:00

224 Views

Suppose we have a list of numbers called nums. If the frequency of a most frequent number in nums is k. We have to find the length of a shortest sublist such that the frequency of its most frequent item is also k.So, if the input is like nums = ... Read More

Program to check right rotation forms increasing or decreasing array with first n natural numbers or not in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 14-Oct-2021 09:53:40

133 Views

Suppose we have a list of numbers called nums, where n elements are present. We have to chesk whether we can make a list with first n natural numbers either in increasing or decreasing fashion, like [1, 2, ..., n] or [n, n - 1, ..., 1] by shifting nums ... Read More

Advertisements