Arnab Chakraborty

Arnab Chakraborty

3,768 Articles Published

Articles by Arnab Chakraborty

Page 58 of 377

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 428 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 462 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

Program to decrypt code to defuse the bomb in Python

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

Suppose there is a bomb that you are going to defuse, and your time is running out! You have a circular array code of length n and have a key k. To decrypt the code, you must replace every number simultaneously based on these rules ? If k > 0 then replace ith number with the sum of next k numbers. If k < 0 then replace ith number with the sum of previous k numbers. If k = 0 then replace ith number with 0. ...

Read More

Program to find maximum in generated array in Python

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

Given a number n, we need to generate an array A of length n + 1 using specific rules and find the maximum value in it. Array Generation Rules The array is built following these rules ? A[0] = 0 A[1] = 1 A[2 * i] = A[i] if 2 ≤ 2 * i ≤ n A[2 * i + 1] = A[i] + A[i + 1] if 2 ≤ 2 * i + 1 ≤ n Example Walkthrough For n = 5, let's see how the array is constructed ? ...

Read More

Program to check we can form array from pieces or not in Python

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

Suppose we have an array nums where all elements are unique and have another array with different smaller arrays called pieces. We have to check whether we can get the main array nums by concatenating the arrays in pieces in any order or not. But we are not allowed to reorder the elements present in each array pieces[i]. So, if the input is like nums = [5, 1, 12, 36, 2, 47, 6] pieces = [[2, 47, 6], [12, 36], [1], [5]], then the output will be True because we can concatenate them in this order [[5], [1], [12, ...

Read More

Program to sort array by increasing frequency of elements in Python

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

Suppose we have an array with some elements where elements may appear multiple times. We have to sort the array such that elements are sorted according to their increasing frequency. Elements that appear fewer times will come first, and when frequencies are equal, larger elements come first. So, if the input is like nums = [1, 5, 3, 1, 3, 1, 2, 5], then the output will be [2, 5, 5, 3, 3, 1, 1, 1] Algorithm Steps To solve this, we will follow these steps ? Create a frequency map to count occurrences of ...

Read More
Showing 571–580 of 3,768 articles
« Prev 1 56 57 58 59 60 377 Next »
Advertisements