Arnab Chakraborty

Arnab Chakraborty

3,768 Articles Published

Articles by Arnab Chakraborty

Page 8 of 377

Python Program to find out the number of rooms in which a prize can be hidden

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 541 Views

Suppose, in a game show there are 2n number of rooms that are arranged in a circle. In one of the rooms, there is a prize that the participants have to collect. The rooms are numbered from 1, 2, 3, ...., n, -n, -(n - 1), ...., -1. in a clockwise manner. Each room has a door and by that door, a different room can be visited. Every door has a marking x on it, which means another room is located at a distance of x from the current room. If the value of x is positive, then the door ...

Read More

Python Program to find out the determinant of a given special matrix

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 530 Views

Suppose, we have a tree with n vertices, where each vertex is labeled from 1 to n. The root of the tree has the label 1, and each vertex weights wi. Now a nxn matrix A is formed where A(x, y) = Wf(x, y) where f(x, y) is the least common predecessor of vertex x and y. We have to find out the determinant of matrix A. The edges of the matrix, weights, and the total number of vertices are given to us as input.So, if the input is like input_array = [[1, 2], [1, 3], [1, 4], [1, 5]], ...

Read More

Program to find maximum population year using Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 649 Views

Suppose we have a table with two columns (birth, death) where each row is representing the birth and death years of the ith person. The population of some year y is the number of people alive during y. The ith person is counted in year y's population when y is in the inclusive range [birth_i, death_i - 1]. (The person is not counted in the year that they die). So, we have to find the earliest year with the maximum population.So, if the input is likeBirthDeath197020101960202019401970then the output will be 2 because there is only one value that matches with ...

Read More

Python Program to find out the number of sets greater than a given value

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 380 Views

Suppose, we have an array containing several integer numbers. We find out all the contiguous subarrays from the given array of numbers and put it into another list. Now, we replace each subarray with the maximum element in that subarray. There is also a number k given to us, and we have to find out how many subarrays are now greater than the given number.So, if the input is like input_array = [5, 6, 7, 8], k = 7, then the output will be 4The contiguous subarrays from the given input array are: {5}, {6}, {7}, {8}, {5, 6}, {6, ...

Read More

Program to find two non-overlapping sub-arrays each with target sum using Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 246 Views

Suppose we have an array of arr and another value target. We have to find two non-overlapping sub-arrays of arr where each has sum equal to target. If there are multiple answers, then we have to find an answer where the sum of the lengths of the two sub-arrays is smallest. We have to find the minimum sum of the lengths of the two required sub-arrays, if there is no such subarray then return -1.So, if the input is like arr = [5, 2, 6, 3, 2, 5] target = 5, then the output will be 2 there are three ...

Read More

Program to find goal parser interpretation command in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 520 Views

Suppose we have a Goal Parser that can interpret a given string command. A command consists ofAn alphabet "G", Opening and closing parenthesis "()"and/or "(al)" in some order.Our Goal Parser will interpret "G" as the string "G", "()" as "o", and "(al)" as the string "al". Finally interpreted strings are then concatenated in the original order. So if we have string command, we have to find the Goal Parser's interpretation of command.So, if the input is like command = "G()()()(al)(al)", then the output will be Goooalal.To solve this, we will follow these steps −s:= blank stringfor i in range 0 ...

Read More

Program to find least number of unique integers after K removals using Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 847 Views

Suppose we have an array called nums where only integers are stored. If we have a number k. We have to find least number of unique elements after removing exactly k elements.So, if the input is like nums = [5, 4, 2, 2, 4, 4, 3], k = 3, then the output will be 2, because if we remove 5 and 3, and either any one of 2s or any one of 4s, then there only 2 and 4 will be left.To solve this, we will follow these steps −dictionary:= a new mapfor each num in nums, doif num is ...

Read More

Program to count the number of consistent strings in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 736 Views

Suppose we have a string s consisting of distinct characters and also have an array of strings called words. A string is consistent when all characters in the string appear in the string s. We have to find the number of consistent strings present in the array words.So, if the input is like s= "px", words = ["ad", "xp", "pppx", "xpp", "apxpa"], then the output will be 3 because there are three strings with only 'p' and 'x', ["xp", "pppx", "xpp"].To solve this, we will follow these steps −count := 0for i in range 0 to size of words - ...

Read More

Program to find minimum number of days to make m bouquets using Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 737 Views

Suppose we have an array with integers called nums, we also have another two values m and k. Now, we need to make m bouquets. To make one bouquet we need k adjacent flowers from the garden. Here the garden consists of n different flowers, the ith flower will bloom in the bloomDay[i]. Each flower can be used inside only one bouquets. We have to find the minimum number of days need to wait to make m bouquets from the garden. If we cannot make m bouquets, then return -1.So, if the input is like bloomDay = [5, 5, 5, ...

Read More

Program to count number of matches played in tournament in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 2K+ Views

Suppose we have a number n. So there are n number of teams in a tournament that has some rules −If the number of teams is even currently, then each team gets merged with another team. And a total of (n/2) matches are played, from them (n/2) winner teams will move to the next round.If the number of teams is odd, then one team randomly moved in the tournament, and the rest gets merged. So a total of (n-1)/2 matches are played, and (n-1)/2+1 teams are moved to the next round as winner.We have to find total number of matches ...

Read More
Showing 71–80 of 3,768 articles
« Prev 1 6 7 8 9 10 377 Next »
Advertisements