Programming Articles

Page 121 of 2547

Program to find out the vertical area between two points where no point lies and is the widest in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 26-Mar-2026 208 Views

Suppose, we are given n number of points as (x, y). A vertical area is an area that is extended infinitely along the y-axis. We have to find out the vertical area between two points such that no other point is inside the area and is the widest. So, if the input is like pts = [[10, 9], [11, 11], [9, 6], [11, 9]], then the output will be 1. ...

Read More

Program to find out the inheritance order in a family in Python

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

In family inheritance systems, we need to track the order of succession when the head of the family dies. This program implements a family inheritance tracker that manages births, deaths, and determines the inheritance order using a depth-first search approach. Problem Overview The inheritance follows these rules: The eldest living member is the head of the family When the head dies, their direct descendants inherit in order Children inherit before siblings The inheritance order follows a depth-first traversal of the family tree ...

Read More

Program to find minimum jumps to reach home in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 26-Mar-2026 491 Views

Suppose there is an array called forbidden, where forbidden[i] indicates that the bug cannot jump to the position forbidden[i], and we also have three values a, b, and x. A bug's home is at position x on the number line. It is at position 0 initially. It can jump by following rules − Bug can jump exactly a positions to the right. Bug can jump exactly b positions to the left. Bug cannot jump backward twice in a row. Bug cannot jump ...

Read More

Program to find out the minimum rotations needed to maximize the profit from a Ferris wheel in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 26-Mar-2026 266 Views

Suppose there is a Ferris wheel with four cabins and each cabin can contain four passengers. The wheel rotates counter-clockwise, and for each rotation, it costs run amount of money. We have an array cust that contains n items where each item i signifies the number of people waiting to get into the Ferris wheel before the i-th rotation. To board the wheel, each customer pays an amount board for one anti-clockwise rotation. The people waiting in line should not wait if there is any vacant seat available in any cabin. ...

Read More

Program to find minimum deletions to make string balanced in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 26-Mar-2026 642 Views

Suppose we have a string s with only two characters 's' and 't'. We can delete any number of characters of s to make the string balanced. We can say, s is balanced when there is no pair of indices (i, j) such that i < j and s[i] = 't' and s[j]= 's'. We have to find the minimum number of deletions needed to make s balanced. So, if the input is like s = "sststtst", then the output will be 2 because we can either remove the characters at indices 2 and 6 ("sststtst" to "sssttt"), or ...

Read More

Program to find maximum profit by selling diminishing-valued colored balls in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 26-Mar-2026 327 Views

Suppose we have an array called inventory, where inventory[i] represents the number of balls of the ith color we have initially. We also have a value called orders, which represents the total number of balls that the customer wants. We can sell the balls in any order, and customers want balls of any color. The values of the balls are special in nature − each colored ball's value equals the current number of balls of that color in our inventory. So if we currently have 6 blue balls, the customer pays 6 for the first blue ball. After selling ...

Read More

Program to find out the farthest building a parkour artist can reach in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 26-Mar-2026 227 Views

A parkour artist wants to traverse buildings of different heights using a limited number of bricks and ladders. Bricks are used for small height differences (each brick covers 1 unit), while ladders can cover any height difference. We need to find the farthest building the artist can reach. Problem Understanding Given an array of building heights, the artist starts at building 0 and moves sequentially. When moving to a taller building, they must use bricks or ladders. The goal is to reach the farthest possible building using the available resources optimally. Example Walkthrough For heights = ...

Read More

Program to check subarrays can be rearranged from arithmetic sequence or not in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 26-Mar-2026 244 Views

Given a sequence of numbers and range queries, we need to check if subarrays can be rearranged to form arithmetic sequences. An arithmetic sequence has a constant difference between consecutive elements. A sequence is arithmetic if it has at least two elements and the difference between consecutive elements remains the same. Examples include [2, 4, 6, 8, 10], [5, 5, 5, 5], and [4, -2, -8, -14]. Problem Example For nums = [6, 8, 7, 11, 5, 9], l = [0, 0, 2], r = [2, 3, 5] ? Query [0, 2]: subarray [6, 8, ...

Read More

Program to split two strings to make palindrome using Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 26-Mar-2026 879 Views

Given two strings a and b of equal length, we need to find if we can split both strings at the same index to create a palindrome by combining parts from different strings. We can split string a into a_pref + a_suff and string b into b_pref + b_suff, then check if a_pref + b_suff or b_pref + a_suff forms a palindrome. Example If a = "pqrst" and b = "turqp", we can split: a → ["pq", "rst"] b → ["tu", "rqp"] Then a_pref + b_suff = "pq" + "rqp" = "pqrqp", which is ...

Read More

Program to find the most competitive subsequence in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 26-Mar-2026 373 Views

A competitive subsequence is a subsequence where elements appear in their original order from the array. Given an array and a target size k, we need to find the most competitive subsequence of size k. A subsequence s1 is more competitive than s2 if at the first differing position, s1 has a smaller number than s2. For example, given nums = [4, 6, 3, 7] and k = 2, among all possible subsequences of size 2: [4, 6], [4, 3], [4, 7], [6, 3], [6, 7], [3, 7], the subsequence [3, 7] is most competitive. Algorithm We ...

Read More
Showing 1201–1210 of 25,469 articles
« Prev 1 119 120 121 122 123 2547 Next »
Advertisements