Server Side Programming Articles

Page 373 of 2109

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

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

Suppose in a game show there are 2n rooms arranged in a circle. One room contains a prize that participants must find. The rooms are numbered 1, 2, 3, ..., n, -n, -(n-1), ..., -1 in clockwise order. Each room has a door with a marking x that indicates the distance to the next room. If x is positive, the door opens to the xth room clockwise; if negative, it opens to the xth room counter-clockwise. We need to find how many rooms can hide the prize such that participants cannot find it by following the door sequence. ...

Read More

Python Program to find out how many cubes are cut

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

Suppose we have several cubes of dimensions a, b, and c, and using them we create a new box of dimension a×b×c. The values a, b, and c are pairwise co-prime, meaning gcd(a, b) = gcd(b, c) = gcd(a, c) = 1. We need to cut the box into two pieces with a single slice and determine how many individual cubes are cut into two pieces. The cut is made through a plane that passes through specific vertices, creating a diagonal slice through the 3D box structure. Problem Statement Given an array containing multiple sets ...

Read More

Python Program to find out how many times the balls will collide in a circular tube

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

Suppose there are n balls in a circular tube that is 100 meters long. Initially, each ball is positioned at a specific distance from a starting point. The balls travel in different directions at a speed of 0.1 meters per second. When two balls meet, they collide and change their direction of travel. We need to find the total number of collisions that occur over 10^9 + 6 seconds. Problem Analysis The key insight is that balls moving in opposite directions will collide multiple times as they circle the tube. The collision count depends on: Number ...

Read More

Python Program to find the number of operations to pack several metal bars in a container

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

Suppose we are given the task to transport several metal bars of different sizes. The transportation container has limited length and can only contain bars of length 1. We are provided n number of bars with their lengths given in a list. To fit all bars in the container, we must cut and divide them into unit sizes, then pack them (which costs one operation per bar). The key insight is that cutting a bar optimally requires finding its prime factorization and cutting along those factors to minimize operations. Problem Analysis For input input_arr = [6, 3, ...

Read More

Python Program to find out the price of a product after a number of days

Arnab Chakraborty
Arnab Chakraborty
Updated on 25-Mar-2026 1K+ Views

Sometimes we need to calculate the price of a product after exponential price increases over multiple days. This problem involves computing modular exponentiation to handle very large numbers efficiently. Problem Understanding Given an initial product price x and number of days y, the price after y days becomes x^y. Since this can result in extremely large numbers, we return the result modulo 10^9 + 7. Algorithm Steps The solution involves the following steps − Iterate through each price-days pair in the input list Extract the initial ...

Read More

Python Program to find out the number of matches in an array containing pairs of (base, number)

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

We need to find pairs in the format (base, number) that represent the same decimal value. For example, (10, 15) means 15 in base 10, and (8, 17) means 17 in base 8. Both equal 15 in decimal, so they match. So, if the input is like num_inputs = 2, input_arr = [(10, 15), (8, 17)], then the output will be 1. The variable num_inputs specifies the number of inputs, and the array input_arr lists the number pairs. Here if we look at the two pairs: 15 in base 10 (decimal) is the same as 17 in base ...

Read More

Python Program to find out the size of the bus that can contain all the friends in the group

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

Suppose there are n number of student groups waiting to get back from their college to their home via the college bus. In each student group, there are m number of students. The student groups want to travel by bus without getting separated. They board the bus if and only if all the members of their group can get on the bus. Also, a group does not board the bus if their previous group has not boarded the bus or has already reached their destination. Given the number of groups and the number of students in each group, we ...

Read More

Program to find wealth of richest customer in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 25-Mar-2026 1K+ Views

Suppose we have a matrix of order m x n called accounts where accounts[i][j] is the amount of money of ith customer present in jth bank. We have to find the wealth that the richest customer has. A customer is richest when he/she has maximum amount considering all banks. Example Input So, if the input is like ? 10 20 15 30 5 20 10 5 12 15 12 3 Then the output will be 55 as the money of second person is 30+5+20 = 55, ...

Read More

Program to find maximum k-repeating substring from sequence in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 25-Mar-2026 1K+ Views

Given a sequence of characters s, we say a string w is k-repeating if w concatenated k times is a substring of the sequence. The maximum k-repeating value of w is the highest value of k where w is k-repeating in the sequence. If w is not a substring of s, its maximum k-repeating value is 0. Problem Statement Given a sequence s and a string w, we need to find the maximum k-repeating value of w in the sequence. For example, if s = "papaya" and w = "pa", the output will be 2 because "pa" ...

Read More

Program to check whether two string arrays are equivalent or not in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 25-Mar-2026 1K+ Views

Suppose we have two string arrays word1 and word2, we need to check whether they represent the same string when their elements are concatenated in order. A string can be represented by an array if concatenating all elements in that array forms the original string. So, if the input is like word1 = ["ko", "lka", "ta"] and word2 = ["k", "olk", "at", "a"], then the output will be True as both arrays form "kolkata" when concatenated. Approach To solve this, we will follow these steps: Initialize two empty strings s1 and s2 ...

Read More
Showing 3721–3730 of 21,090 articles
« Prev 1 371 372 373 374 375 2109 Next »
Advertisements