Arnab Chakraborty

Arnab Chakraborty

3,768 Articles Published

Articles by Arnab Chakraborty

Page 137 of 377

Find if neat arrangement of cups and shelves can be made in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 25-Mar-2026 189 Views

Suppose we have three different types of cups in array p and saucers in array q, and m number of shelves. We need to check whether a neat arrangement of cups and saucers can be made following specific constraints. The arrangement is considered neat if it follows these conditions: No shelf can hold both cups and saucers A shelf may contain at most 5 cups A shelf may contain at most 10 saucers Problem Understanding Given arrays p = [4, 3, 7], q = [5, 9, 10], and m = 11, we need to ...

Read More

Find if it is possible to get a ratio from given ranges of costs and quantities in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 25-Mar-2026 140 Views

Suppose we have a range of cost from lowCost to upCost and another range of quantity from lowQuant to upQuant. We need to check whether we can find the given ratio r where r = cost/quantity, with lowCost ≤ cost ≤ upCost and lowQuant ≤ quantity ≤ upQuant. So, if the input is like lowCost = 2, upCost = 10, lowQuant = 3, upQuant = 9 and r = 3, then the output will be True as the cost = r * quantity = 3 * 3 = 9 where cost is in range [2, 10] and quantity is ...

Read More

Find if given vertical level of binary tree is sorted or not in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 25-Mar-2026 164 Views

In binary tree problems, we often need to analyze nodes at specific vertical levels. A vertical level represents all nodes that are at the same horizontal distance from the root. This problem asks us to check if nodes at a given vertical level are sorted in ascending order. Understanding Vertical Levels In a binary tree, vertical levels are determined by horizontal distance from the root ? Root node is at vertical level 0 Left child is at (parent's level - 1) Right child is at (parent's level + 1) ...

Read More

Find if an undirected graph contains an independent set of a given size in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 25-Mar-2026 384 Views

An independent set in an undirected graph is a set of vertices where no two vertices are adjacent (directly connected by an edge). This article demonstrates how to find if a graph contains an independent set of a given size using Python. We need to check whether a graph contains an independent set of size k. If such a set exists, return "Yes", otherwise "No". Problem Understanding Given an undirected graph represented as an adjacency matrix, we want to find k vertices such that none of them are connected to each other. For example, if k = ...

Read More

Find Four points such that they form a square whose sides are parallel to x and y axes in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 25-Mar-2026 602 Views

Finding four points that form a square with sides parallel to the coordinate axes is a geometric problem. We need to identify diagonal points first, then verify if the other two corner points exist in our point set. Problem Approach To form a square with sides parallel to x and y axes, we need four points that satisfy these conditions ? Two points should form a diagonal of the square The diagonal points must have equal x-distance and y-distance The other two corner points must exist in our point set If multiple squares exist, select the ...

Read More

Find four missing numbers in an array containing elements from 1 to N in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 25-Mar-2026 268 Views

Finding missing numbers in an array is a common programming problem. When we have an array of distinct numbers from range [1, N] with size (N-4), exactly four numbers are missing. This problem can be solved efficiently using array manipulation techniques. Problem Understanding Given an array of distinct numbers where: Each number lies in range [1, N] Array size is (N-4) No element is repeated We need to find 4 missing numbers in sorted order For example, if A = [2, 8, 4, 13, 6, 11, 9, 5, 10], then N = 13 and the ...

Read More

Find First element in AP which is multiple of given Prime in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 25-Mar-2026 143 Views

In this problem, we need to find the position of the first element in an Arithmetic Progression (AP) that is divisible by a given prime number. Given the first term A, common difference D, and prime number P, we use modular arithmetic to efficiently find this position. For example, if A = 3, D = 4, P = 5, the AP terms are: 3, 7, 11, 15, 19... The fourth term (15) is the first multiple of 5, so the answer is 3 (0-indexed position). Algorithm Approach The solution uses Fermat's Little Theorem and modular exponentiation. For ...

Read More

Find element position in given monotonic sequence in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 25-Mar-2026 331 Views

When working with monotonic sequences, we often need to find the position where a specific value occurs. This problem involves a monotonic increasing sequence defined by the function f(m) = am + bm[log₂(m)] + cm³, where [log₂(m)] represents the floor of log base 2. Understanding the Formula The sequence function f(m) = am + bm[log₂(m)] + cm³ contains three components: Linear term: am (where a = 1, 2, 3, ...) Logarithmic term: bm[log₂(m)] (where b = 1, 2, 3, ...) Cubic term: cm³ (where c = 0, 1, 2, 3, ...) The floor logarithm ...

Read More

Find Duplicates of array using bit array in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 25-Mar-2026 243 Views

Suppose we have an array of n different numbers; n can be 32, 000 at max. The array may have duplicate entries and we do not know what is the value of n. Now if we have only 4-Kilobytes of memory, how would display all duplicates in the array? So, if the input is like [2, 6, 2, 11, 13, 11], then the output will be [2, 11] as 2 and 11 appear more than once in given array. How Bit Array Works A bit array uses individual bits to track whether a number has been seen ...

Read More

Find distinct elements common to all rows of a matrix in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 25-Mar-2026 362 Views

Finding distinct elements common to all rows of a matrix is a useful operation in data analysis. We need to identify elements that appear in every row of the matrix, regardless of their position. So, if the input matrix is: 13 2 15 4 17 15 3 2 4 36 15 2 15 4 12 15 26 4 3 2 2 19 4 22 15 Then the output will be [2, 4, 15], as these elements appear in all rows. Using Set ...

Read More
Showing 1361–1370 of 3,768 articles
« Prev 1 135 136 137 138 139 377 Next »
Advertisements