Arnab Chakraborty has Published 4173 Articles

Program to find total duration of K most watched shows in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 11-Oct-2021 07:41:27

179 Views

Suppose we have a list of list of strings called shows, also have a list of integers called durations, and another value k, here shows[i] and durations[i] represent a show and its duration watched by the ith man, we have to find the total duration watched of the k most ... Read More

Program to find expected value of given equation for random numbers in Python

Arnab Chakraborty

Arnab Chakraborty

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

311 Views

Suppose we have a number n. Consider x = rand() mod n, where rand() function generates integers between 0 and 10^100 (both inclusive) uniformly at random. And$$Y = \sqrt{x+\sqrt{x+\sqrt{x+\sqrt{x+...}}}}$$We have to find the expected value of Y. The value of n will be in range 1 and 5*10^6.So, if the ... Read More

Program to count number of intervals which are intersecting at given point in Python

Arnab Chakraborty

Arnab Chakraborty

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

346 Views

Suppose we have a list of intervals and a value called point. Each interval interval[i] contains [si, ei] represents start time and end time of interval i (both inclusive). We have to find the number of intervals that are intersecting at given point.So, if the input is like intervals = ... Read More

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

1K+ 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

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

Arnab Chakraborty

Arnab Chakraborty

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

4K+ 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

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 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

Advertisements