Arnab Chakraborty has Published 4452 Articles

Program to insert new element into a linked list before the given position in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 11-Oct-2021 07:35:37

836 Views

Suppose we have a list of elements; these elements are stored in a singly linked list. We also have a value pos and value val. We have to insert val before index pos of the linked list.So, if the input is like nums = [1, 5, 3, 6, 8] pos ... Read More

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

92 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

489 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 find highest common factor of a list of elements in Python

Arnab Chakraborty

Arnab Chakraborty

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

3K+ Views

Suppose we have a list of elements called nums, we have to find the largest positive value that divides each of the integers.So, if the input is like nums = [15, 81, 78], then the output will be 3, as 3 is the largest integer that divides all 15, 81, ... 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

501 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

389 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 check given number is a Fibonacci term in Python

Arnab Chakraborty

Arnab Chakraborty

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

2K+ Views

Suppose we have a number say n. We have to check whether n is present in Fibonacci sequence or not. As we know in Fibonacci sequence f(i) = f(i-1) + f(i-2) for each i from 2 to n, and f(0) = 0, f(1) = 1.So, if the input is like ... 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

95 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

184 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 local peak element indices from a list of numbers in Python

Arnab Chakraborty

Arnab Chakraborty

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

311 Views

Suppose we have a list of numbers called nums whose length is at least 2. We have to find the index of every peak in the list. The list is sorted in ascending order. An index i is a peak when −nums[i] > nums[i + 1] when i = 0nums[i] ... Read More

Advertisements