Arnab Chakraborty has Published 4452 Articles

Program to check number of global and local inversions are same or not in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Nov-2020 06:30:40

93 Views

Suppose we have a list of distinct numbers called nums. Here a global inversion is when there's indices i < j such that nums[i] > nums[j]. And local inversion is when there is an index i and i + 1 such that nums[i] > nums[i + 1]. We have to ... Read More

Program to merge intervals and sort them in ascending order in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Nov-2020 06:28:45

643 Views

Suppose we have a list intervals, we have to find the union of them in sorted sequence.So, if the input is like inv = [[2, 5], [4, 10], [20, 25]], then the output will be [[2, 10], [20, 25]]To solve this, we will follow these steps −sort the list intervalsans ... Read More

Program to find overlapping intervals and return them in ascending order in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Nov-2020 06:26:33

212 Views

Suppose we have a list of closed intervals and another list of intervals. Individually, each list is non-overlapping and they are sorted in non-decreasing order. We have to find the overlap of the two intervals sorted in non-decreasing order.So, if the input is like inv1 = [[50, 100], [190, 270], ... Read More

Program to find total unique duration from a list of intervals in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Nov-2020 06:25:00

910 Views

Suppose we have a list of intervals where each list represents an interval [start, end] (inclusive). We have to find the total unique duration it covers.So, if the input is like intervals = [[2, 11], [13, 31], [41, 61]], then the output will be 50, as the total unique covered ... Read More

Program to find intervals that do not intersect the cut interval in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Nov-2020 06:23:27

170 Views

Suppose we have a sorted and disjoint intervals list and another list cut, that represents an interval. We have to delete all parts of intervals that are intersecting with cut interval, and return the new list.So, if the input is like intervals = [[2, 11], [13, 31], [41, 61]] cut ... Read More

Program to find Inorder Successor of a binary search tree in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Nov-2020 06:21:30

520 Views

Suppose we have a binary search tree BST and another value of a node, we have to find the in-order successor of that node in the BST. As we all know that the successor of a node p is the node with the smallest key greater than the value of ... Read More

Program to find number of minimum steps to reach last index in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Nov-2020 06:19:24

437 Views

Suppose we have a list of numbers called nums and we are placed currently at nums[0]. On each step, we can either jump from the current index i to i + 1 or i - 1 or j where nums[i] == nums[j]. We have to find the minimum number of ... Read More

Program to find H-Index from a list of citations in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Nov-2020 06:17:15

239 Views

Suppose we have an array of citations of a researcher. We have to define a function to compute the researcher's h-index. As we know the h-index is a metric used to calculate the impact of a researcher's papers. Formally H-index can be defined as: "A researcher has index h if ... Read More

Program to find number of friend groups in a set of friends connections in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Nov-2020 06:15:35

579 Views

Suppose we have a a friends list, where friends[i] is a list of people i is friends with. The connection of friendships are two-way. And each person is friend with themselves and two people are in a friend group as long as there is some path of mutual friends connecting ... Read More

Program to find maximum sum by flipping each row elements in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Nov-2020 06:13:02

182 Views

Suppose we have a 2D binary matrix. For any row or column in the given matrix we can flip all the bits. If we can perform any number of these operations, and that we treat each row as a binary number, we have to find the largest sum that can ... Read More

Advertisements