Arnab Chakraborty has Published 4452 Articles

Program to find multiple of n with only two digits in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 11-Oct-2021 07:15:16

142 Views

Suppose we have a number n. We have to find the least positive value x such that x is made up of only two digits 9's and 0's, and x is multiple of n.So, if the input is like n = 26, then the output will be 90090.To solve this, ... Read More

Program to check whether elements frequencies are even or not in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 11-Oct-2021 07:14:01

67 Views

Suppose we have a list of elements called nums, we have to check whether all numbers appear even times or not. We have to solve it using constant space.So, if the input is like nums = [8, 9, 9, 8, 5, 5], then the output will be True, because all ... Read More

Program to check same value and frequency element is there or not in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 11-Oct-2021 07:12:26

99 Views

Suppose we have a list of numbers called nums, we have to check whether there is an element whose frequency is same as its value.So, if the input is like nums = [2, 5, 7, 5, 3, 5, 3, 5, 9, 9, 5], then the output will be True, because ... Read More

Program to count index pairs for which array elements are same in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 11-Oct-2021 07:09:51

532 Views

Suppose we have a list of numbers called nums. We have to find the number of pairs i < j such that nums[i] and nums[j] are same.So, if the input is like nums = [5, 4, 5, 4, 4], then the output will be 4, as We have index pairs ... Read More

Program to sort given set of Cartesian points based on polar angles in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 11-Oct-2021 07:05:51

917 Views

Suppose we have a set of Cartesian points in a list called points. We have to sort them based on their polar angles. The polar angles vary in range 0 and 2*PI. If some points have same polar angles, then arrange them based on the distance of that point from ... Read More

Program to find duplicate item from a list of elements in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 11-Oct-2021 07:00:09

139 Views

Suppose we have a list of elements called nums of size n + 1, they are selected from range 1, 2, ..., n. As we know, by pigeonhole principle, there must be a duplicate. We have to find the duplicate. Here our target is to find the task in O(n) ... Read More

Program to count elements whose next element also in the array in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 11-Oct-2021 06:57:47

135 Views

Suppose we have a list of numbers say nums, we have to find the number of elements x in the array, such that x + 1 also exists in the array.So, if the input is like nums = [4, 2, 3, 3, 7, 9], then the output will be 3, ... Read More

Program to find number of optimal steps needed to reach destination by baby and giant steps in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 11-Oct-2021 06:57:45

288 Views

Suppose we have a list of queries Q, where each query Q[i] contains a triplet [a_i, b_i and d_i]. Consider we are at position (0, 0) initially, then in one step we can move from some position (x1, y1) to (x2, y2) where Euclidean distance between these two points is ... Read More

Program to check all 1s are present one after another or not in Python

Arnab Chakraborty

Arnab Chakraborty

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

106 Views

Suppose we have a list of numbers called nums that contains at least one element whose value is 1. We have to check whether all the 1s appear consecutively or not.So, if the input is like nums = [8, 2, 1, 1, 1, 3, 5], then the output will be ... Read More

Program to find removed term from arithmetic sequence in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 11-Oct-2021 06:54:06

107 Views

Suppose we have an array called nums holding n-1 arithmetic sequence terms. One element except the first or last element of nums was removed before. We have to find the removed number.So, if the input is like nums = [5, 7, 11, 13], then the output will be 9 because, ... Read More

Advertisements