Arnab Chakraborty has Published 4452 Articles

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

582 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

496 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

206 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

253 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

147 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

72 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

Program to define set data structure without using library set class in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 14-Oct-2021 09:51:20

207 Views

Suppose we want to implement a set data structure with the following methods −Constructor to construct a new instance of a setadd(val) to insert integer val into the setexists(val) to check whether val is in the set or notremove(val) to remove the val from the setSo, if we construct a ... Read More

Program to check whether all can get a seat or not in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 14-Oct-2021 09:48:20

421 Views

Suppose we have a number n, there are n number of people searching for a seat, we also have a list of bits where 1 represents an already occupied seat and 0 represents empty seat. No two people can sit next to each other, so we have to check whether ... Read More

Program to implement run length string decoding iterator class in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 14-Oct-2021 09:44:59

169 Views

Suppose we want to define an iterator class that constructs with a run-length encoded lowercase string say s, there are two functions for this iterator they are −next() this finds the next element in the iteratorhasnext() this checks whether the next element is present or notSo, if the input is ... Read More

Advertisements