Arnab Chakraborty has Published 4293 Articles

Find four factors of N with maximum product and sum equal to N - Set-2 in Python Program

Arnab Chakraborty

Arnab Chakraborty

Updated on 25-Aug-2020 12:05:51

146 Views

Suppose we have a number N, we have to find all factors of N and return the product of four factors of N such that: The sum of the four factors is same as N. The product of the four factors is maximum. All four factors can be equal to ... Read More

Find pairs with given product in a sorted Doubly Linked List in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 25-Aug-2020 11:57:03

163 Views

Suppose we have a sorted doubly linked list of unique positive numbers; we have to find pairs in the doubly linked list whose product is same as a given value x. We have to keep in mind that, this will be solved without consuming any extra space.So, if the input ... Read More

Find original numbers from gcd() every pair in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 25-Aug-2020 11:53:03

204 Views

Suppose we have an array A where GCD of every possible pair of elements of another array is given, we have to find the original numbers which are used to compute the given GCD array.So, if the input is like A = [6, 1, 1, 13], then the output will ... Read More

Find nth term of a given recurrence relation in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 25-Aug-2020 11:50:13

679 Views

Suppose we have a sequence of numbers called bn, this is represented using a recurrence relation like b1=1 and bn+1/bn=2n . We have to find the value of log2(bn) for a given n.So, if the input is like 6, then the output will be 5 as log2(bn) = (n * ... Read More

Find n-th lexicographically permutation of a strings in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 25-Aug-2020 11:47:23

285 Views

Suppose we have a string whose length is m, and this string is containing only lowercase letters, we have to find the n-th permutation of string lexicographically.So, if the input is like string = "pqr", n = 3, then the output will be "qpr" as all permutations are [pqr, prq, ... Read More

Find N distinct numbers whose bitwise Or is equal to K in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 25-Aug-2020 11:43:59

159 Views

Suppose we have two integers N and K; we have to find N unique values whose bit-wise OR is same as K. If there is no such result, then return -1So, if the input is like N = 4 and K = 6, then the output will be [6, 0, ... Read More

Find missing element in a sorted array of consecutive numbers in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 25-Aug-2020 11:40:46

565 Views

Suppose we have an array A of n unique numbers, these n elements are present in the array in ascending order, but there is one missing element. We have to find the missing element.So, if the input is like A = [1, 2, 3, 4, 5, 6, 7, 9], then ... Read More

Find minimum time to finish all jobs with given constraints in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 25-Aug-2020 11:36:09

498 Views

Suppose we have an array of jobs with different time requirements, there are k different persons to assign jobs and we also have how much time t an assignee takes to do one unit of the job. We have to find the minimum time to complete all jobs with following ... Read More

Find minimum adjustment cost of an array in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 25-Aug-2020 11:31:24

550 Views

Suppose we have an array of positive numbers; we replace each element from that array array so that the difference between two adjacent elements in the array is either less than or equal to a given target. Now, we have to minimize the adjustment cost, so the sum of differences ... Read More

Find median of BST in O(n) time and O(1) space in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 25-Aug-2020 11:28:40

537 Views

Suppose we have Binary Search Tree(BST), we have to find median of it. We know for even number of nodes, median = ((n/2th node + (n+1)/2th node) /2 For odd number of nodes, median = (n+1)/2th node.So, if the input is likethen the output will be 7To solve this, we ... Read More

Advertisements