Programming Articles

Page 105 of 2547

Find the missing value from the given equation a + b = c in Python

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

In Python, we can solve equations of the form a + b = c where one value is missing (represented by ?). This involves parsing the equation string and applying basic arithmetic to find the unknown value. For example, if the input is ? + 4 = 9, the output will be 5. Algorithm To solve this problem, we follow these steps: Remove all spaces from the string and replace + and = with commas Split the string by commas to get individual elements Find the position of the missing value (?) Apply the appropriate ...

Read More

Find the minimum time after which one can exchange notes in Python

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

Suppose there are n cashiers exchanging money. At any moment, the i-th cashier has ki people waiting in line. The j-th person in line for the i-th cashier has m[i, j] notes to exchange. We need to find the minimum time required to exchange notes, given that each cashier takes 5 seconds to scan a single note and 15 seconds to complete the exchange process for each customer. Problem Understanding The total time for each cashier consists of ? Scanning time: 5 seconds × total notes for all customers Exchange time: 15 seconds × number of ...

Read More

How to use PowerShell Help commands?

Chirag Nagrekar
Chirag Nagrekar
Updated on 25-Mar-2026 5K+ Views

I notice there's a mismatch - the topic mentions "PowerShell Help commands" but you've asked me to improve this as a Python article following Python formatting rules. Since the content is clearly about PowerShell (not Python), I'll improve it as a PowerShell tutorial while following the general article improvement guidelines. PowerShell provides comprehensive help documentation for all cmdlets through the Get-Help cmdlet (alias: help). This built-in help system allows you to quickly access command syntax, parameters, and examples. Basic Help Usage To get help for any PowerShell command, use the Get-Help cmdlet followed by the command name ...

Read More

Find four factors of N with maximum product and sum equal to N - Set-2 in Python Program

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

Given a number N, we need to find four factors of N such that their sum equals N and their product is maximized. The factors can be repeated to achieve the maximum product. So, if the input is N = 60, then the output will be: All factors are [1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30, 60] and the maximum product is 50625, where 15 is selected four times (15 + 15 + 15 + 15 = 60 and 15 × 15 × 15 × 15 = 50625). Algorithm Steps To solve this ...

Read More

Find pairs with given product in a sorted Doubly Linked List in Python

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

Finding pairs with a given product in a sorted doubly linked list is an efficient algorithm that uses the two-pointer technique. Given a sorted doubly linked list of unique positive numbers, we need to find all pairs whose product equals a target value x, without using extra space. For example, if we have a doubly linked list: 1 ⇄ 2 ⇄ 4 ⇄ 5 ⇄ 6 ⇄ 8 ⇄ 9 and target x = 8, the pairs would be (1, 8) and (2, 4). Algorithm Steps The solution uses two pointers starting from opposite ends of the ...

Read More

Find original numbers from gcd() every pair in Python

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

Given an array containing GCD (Greatest Common Divisor) values of every possible pair from an original array, we need to reconstruct the original numbers. This is a reverse engineering problem where we work backwards from the GCD results. Problem Understanding If we have an original array like [13, 6], the GCD array would contain ? gcd(13, 13) = 13 gcd(13, 6) = 1 gcd(6, 13) = 1 gcd(6, 6) = 6 So the GCD array becomes [13, 1, 1, 6]. Our task is to reverse this process. Algorithm Steps The key insight ...

Read More

Find nth term of a given recurrence relation in Python

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

A recurrence relation defines a sequence where each term is expressed using previous terms. Given the relation b1=1 and bn+1/bn=2n, we need to find log2(bn) for any given n. Understanding the Mathematical Solution To solve this recurrence relation, we can derive the general formula step by step ? Starting with the given relation: bn+1/bn = 2n bn/bn-1 = 2n-1 ... b2/b1 = 21 Multiplying all these equations together: (bn+1/bn) × (bn/bn-1) × ... × (b2/b1) = 2n + (n-1) + ... + 1 This simplifies to: bn+1/b1 = 2n(n+1)/2 Since b1 = 1, we ...

Read More

Find n-th lexicographically permutation of a strings in Python

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

Finding the n-th lexicographically ordered permutation of a string is a classic combinatorial problem. Given a string with lowercase letters, we need to find the specific permutation that would appear at position n when all permutations are sorted alphabetically. For example, if we have string = "pqr" and n = 3, all permutations in lexicographic order are: [pqr, prq, qpr, qrp, rpq, rqp]. The 3rd permutation is "qpr". Algorithm Overview The algorithm uses factorial number system to efficiently find the n-th permutation without generating all permutations ? Precompute factorials for quick ...

Read More

Find N distinct numbers whose bitwise Or is equal to K in Python

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

Given two integers N and K, we need to find N distinct numbers whose bitwise OR equals K. If no such combination exists, we return -1. For example, if N = 4 and K = 6, one possible output is [6, 0, 1, 2] because 6 | 0 | 1 | 2 = 6. Algorithm Approach The key insight is that we need at least 2^(number of set bits in K) different numbers to construct all possible combinations. We start with K itself, then generate additional numbers by systematically setting different bit patterns. Implementation ...

Read More

Find missing element in a sorted array of consecutive numbers in Python

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

When working with a sorted array of consecutive numbers that has one missing element, we can use binary search to efficiently find the missing number in O(log n) time complexity. So, if the input is like A = [1, 2, 3, 4, 5, 6, 7, 9], then the output will be 8. Algorithm The approach uses binary search with the following logic ? For each element at index i, if no element is missing before it, then A[i] - i should equal A[0] If A[mid] - mid equals A[0], the missing element is in the ...

Read More
Showing 1041–1050 of 25,469 articles
« Prev 1 103 104 105 106 107 2547 Next »
Advertisements