Arnab Chakraborty has Published 4452 Articles

Program to find minimum interval to include each query in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 08-Oct-2021 08:42:27

280 Views

Suppose we have a list of intervals, where intervals[i] has a pair (left_i, right_i) represents the ith interval starting at left_i and ending at right_i (both inclusive). We also have another array called queries. The answer to the jth query is the size of the smallest interval i such that ... Read More

Program to find closest room from queries in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 08-Oct-2021 08:31:02

112 Views

Suppose there is an array called rooms. where rooms[i] contains a pair [roomId_i, size_i] denotes a room whose id is roomId_i and size is size_i. All room numbers are distinct. We also have another array queries, where queries[j] contains a pair [preferred_j, minSize_j]. The answer to the jth query is ... Read More

Program to find maximum building height in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 08-Oct-2021 08:27:50

603 Views

Suppose we have a value n and another list of pairs called restrictions. We want to build n new buildings in a city. But there are few restrictions. We can built in a line and buildings are labeled from 1 to n. The restrictions has two parameters, so restrictions[i] = ... Read More

Program to find XOR sum of all pairs bitwise AND in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 08-Oct-2021 08:24:37

1K+ Views

Suppose we have two arrays arr1 and arr2. The XOR sum of a list is the bitwise XOR of all of its elements. If the list has only one element, then its XOR sum will be the element itself. Now, consider the list has the result of arr1[i] AND arr2[j] ... Read More

Program to find minimum number of operations to make string sorted in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 08-Oct-2021 08:19:25

208 Views

Suppose we have a string s. We have to perform the following operation on s until we get a sorted string −Select largest index i such that 1

Program to find number of different subsequences GCDs in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 08-Oct-2021 08:08:56

124 Views

Suppose we have an array nums with positive values. We have to find the number of different GCDs among all non-empty subsequences of nums. As we know the GCD of a sequence of numbers is the greatest value that divides all the numbers in the sequence evenly.So, if the input ... Read More

Program to find maximum number of groups getting fresh donuts in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 08-Oct-2021 07:58:58

79 Views

Suppose we have a value batchSize and an array group where groups[i] denotes that there is a group of groups[i] customers that will visit the shop. So there is a donuts shop that bakes donuts in batches of given batchSize. But they have one rule, they must serve all of ... Read More

Program to maximize number of nice divisors in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 08-Oct-2021 07:55:56

101 Views

Suppose we have a number pf represents number of prime factors. We have to make a positive number n that satisfies the following conditions −The number of prime factors of n (may or may not be distinct) is at most pf.The number of nice divisors of n is maximized. As ... Read More

Program to count pairs with XOR in a range in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 08-Oct-2021 07:53:47

342 Views

Suppose we have an array nums and have two values l and r, we have to find the number of nice pairs. Here a nice pair is a pair (i, j) where 0 >= 1       return res // 2    return test(nums, r + 1) - ... Read More

Program to find maximize score after n operations in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 08-Oct-2021 07:50:20

426 Views

Suppose we have an array called nums, whose size is 2*n. We have to perform n operations on this array. In the ith operation (1-indexed), we will do the following:Select two elements, x and y.Get a score of i*gcd(x, y).Remove x and y from the array nums.We have to find ... Read More

Advertisements