Articles on Trending Technologies

Technical articles with clear explanations and examples

Program to find out the conversion rate of two currencies in Python

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

Currency conversion is a common problem in financial applications. Given three arrays containing source currencies, destination currencies, and their conversion rates, we need to find the conversion rate between any two currencies using the available exchange paths. The problem provides curr_a (source currencies), curr_b (destination currencies), and conv_rate (conversion rates). We need to find the conversion rate from a source currency to a destination currency, returning 0 if no path exists. Problem Analysis If the input is src = "INR", dest = "JPY", curr_a = ["INR", "GBP", "EUR"], curr_b = ["GBP", "EUR", "JPY"], conv_rate = [0.009, 1.17, ...

Read More

Program to find dot product of run length encoded vectors in Python

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

Suppose we have two lists nums1 and nums2. Each of these two lists represents a vector in run-length encoded form. For example, a vector [1, 1, 1, 2, 2, 2, 2] is represented as [3, 1, 4, 2] (because there are 3 ones and 4 twos). We need to find the dot product of these two vectors, which is the sum of element-wise multiplication of items present in two vectors. So, if the input is like nums1 = [2, 7, 5, 3] and nums2 = [3, 5, 4, 2], then the output will be 109 because: The vectors ...

Read More

Program to check there is any common reachable node in a graph or not in Python

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

Suppose we have an edge list of a directed graph with n nodes numbered from 0 to n-1. Given two integer values a and b, we need to check whether there exists a node c such that we can reach both a and b from c. 0 1 2 3 4 ...

Read More

Program to find maximum coins we can get from disappearing coins matrix in Python

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

When we have a 2D matrix where each cell represents coins, we need to find the maximum coins we can collect with specific constraints. When we pick coins from matrix[r, c], all coins in adjacent rows (r-1 and r+1) and adjacent columns (c-1 and c+1) disappear. This problem can be solved using dynamic programming by treating it as two separate "House Robber" problems − first for each row, then for the resulting row sums. Problem Understanding Given the input matrix ? 2876 101042 5923 We can pick cells with coins 8, 6, 9, ...

Read More

Program to check all tasks can be executed using given server cores or not in Python

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

Suppose we have two lists: cores and tasks. The cores[i] indicates the number of cores available in the ith server, and tasks[i] indicates the number of cores needed to execute that task. Each task must be run on only one server, and a server may have multiple tasks to run. We need to check whether it's possible to run all tasks with the given server cores. For example, if cores = [10, 7] and tasks = [7, 3, 2, 2, 1], the output will be True because we can assign tasks[0] (7 cores) and tasks[1] (3 cores) to the ...

Read More

Program to check there is any forward path in circular cyclic list or not in Python

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

Suppose we have a circular list called nums where the first and last elements are neighbors. Starting from any index i, we can move nums[i] number of steps forward if nums[i] is positive, or backwards if it's negative. We need to check whether there is a cycle with length greater than one that moves only in one direction (either all forward or all backward). For example, if the input is nums = [-1, 2, -1, 1, 2], the output will be True because there is a forward path: [1 → 3 → 4 → 1]. Algorithm Steps ...

Read More

Program to count number of characters in each bracket depth in Python

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

Sometimes we need to count characters at different bracket depths in a string. This problem involves parsing a string with balanced brackets "(", ")" and characters "X", then counting how many "X" characters appear at each depth level. So, if the input is like s = "(XXX(X(XX))XX)", then the output will be [5, 1, 2] Bracket Depth Visualization ( X X X ( X ( X X ) ...

Read More

Program to get final string after shifting characters with given number of positions in Python

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

Suppose we have a lowercase string s and another list of integers called shifts whose length is same as the length of s. Here each element in shifts[i] indicates it to shift the first i + 1 letters of s by shifts[i] positions. If shifting crosses 'z' it will wrap up to 'a'. We have to find the resulting string after applying shifts to s. So, if the input is like s = "tomato" shifts = [2, 5, 2, 3, 7, 4], then the output will be "qjcoes". After shifting first character 2 places, it will be 't' to ...

Read More

Program to count number of horizontal brick pattern can be made from set of bricks in Python

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

Suppose we have a list of numbers called bricks and two other values width and height. Each element in bricks[i] represents a brick whose length is bricks[i] units and width is 1 unit. We have to find the number of ways to lay the bricks such that we get full layout of bricks with the given width and height. We can reuse the bricks but can only be laid horizontally. So, if the input is like bricks = [2, 1] width = 3 height = 2, then the output will be 9 because − ...

Read More

Program to find number of pairs where elements square is within the given range in Python

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

Given two lists of numbers nums1 and nums2, and two boundary values lower and upper, we need to find the number of pairs (i, j) such that lower ≤ nums1[i]² + nums2[j]² ≤ upper. Problem Understanding For example, if nums1 = [5, 3, 2], nums2 = [8, 12, 6], lower = 10, and upper = 50, we need to check all possible combinations: Pair (1, 2): 3² + 6² = 9 + 36 = 45 (10 ≤ 45 ≤ 50) ✓ Pair (2, 2): 2² + 6² = 4 + 36 = 40 (10 ≤ 40 ...

Read More
Showing 2901–2910 of 61,297 articles
« Prev 1 289 290 291 292 293 6130 Next »
Advertisements