Arnab Chakraborty has Published 3734 Articles

Program to find size of common special substrings of two given strings in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 11-Oct-2021 07:29:17

192 Views

Suppose we have two strings s1 and s2. We have to find the size of longest string s3 which is special substring of both s1 and s2.We can say a string x is special substring of another string y if x can be generated by removing 0 or more characters ... Read More

Program to find index whose left and right elements sums are equal in Python

Arnab Chakraborty

Arnab Chakraborty

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

729 Views

Suppose we have a list of items called nums, we have to find the smallest index i such that the sum of the numbers which are present at the left of i is equal to the sum of numbers present at right of i. If we cannot find any such ... Read More

Program to check n can be represented as sum of k primes or not in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 11-Oct-2021 07:25:38

742 Views

Suppose we have two inputs n and k. We have to check whether n can be represented as a sum of k number of prime values or not.So, if the input is like n = 30 k = 3, then the output will be True because 30 can be represented ... Read More

Program to find all substrings whose anagrams are present in a string in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 11-Oct-2021 07:22:40

537 Views

Suppose we have a string s with lowercase letters. We have to find all in s where there must be another substring in s at a different location that is an anagram of that taken substrings. We have to find a list of substrings in in lexicographic order.So, if the ... Read More

Program to find smallest index for which array element is also same as index in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 11-Oct-2021 07:20:25

191 Views

Suppose we have a list of elements called nums where all items are unique, and they are sorted in ascending order, we have to find the minimum i such that nums[i] = i. If we cannot find any solution, then return -1. We have to solve this problem in O(log(n)) ... Read More

Program to find first fit room from a list of rooms in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 11-Oct-2021 07:18:40

272 Views

Suppose we have a list of numbers called rooms and another target value t. We have to find the first value in rooms whose value is at least t. If there is no such room, return -1.So, if the input is like rooms = [20, 15, 35, 55, 30] t ... Read More

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

Arnab Chakraborty

Arnab Chakraborty

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

281 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

142 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 sort given set of Cartesian points based on polar angles in Python

Arnab Chakraborty

Arnab Chakraborty

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

1K+ 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 count elements whose next element also in the array in Python

Arnab Chakraborty

Arnab Chakraborty

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

256 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

Advertisements