Arnab Chakraborty

Arnab Chakraborty

3,768 Articles Published

Articles by Arnab Chakraborty

Page 51 of 377

Program to perform excel spreadsheet operation in Python?

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

Excel spreadsheets contain cells with values, formulas, or cell references. In Python, we can simulate this by processing a 2D matrix where each cell can contain a number, a cell reference (like "B1"), or a formula (like "=A1+A2"). Problem Understanding Given a 2D matrix representing an Excel spreadsheet, we need to evaluate all formulas and cell references to get the final computed values. Columns are labeled A, B, C... and rows are numbered 1, 2, 3... Input Matrix Output Matrix B170 35=A1+A2 770 3510 ...

Read More

Program to count number of operations required to convert all values into same in Python?

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

Given a list of integers, you can perform the following operation: pick the largest number and turn it into the second largest number. We need to find the minimum number of operations required to make all integers the same in the list. For example, if the input is nums = [5, 9, 2], the output will be 3. Here's how: pick 9 first, then make it 5, so array becomes [5, 5, 2]. Then pick 5 and make it 2, getting [5, 2, 2]. Again pick 5 and convert it into 2, resulting in [2, 2, 2]. Algorithm ...

Read More

Program to check whether we can make group of two partitions with equal sum or not in Python?

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

Suppose we have a list of numbers called nums, we have to check whether we can partition nums into two groups where the sum of the elements in both groups are the same. So, if the input is like nums = [2, 3, 6, 5], then the output will be True, as we can make groups like: [2, 6] and [3, 5]. Algorithm To solve this, we will follow these steps − total := sum of all elements in nums if total is odd, then ...

Read More

Program to enclose pattern into bold tag in Python?

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

When working with text processing, you often need to highlight specific patterns by wrapping them in HTML tags. This problem involves finding all occurrences of given patterns in a text and enclosing them in tags, while merging overlapping or adjacent patterns. Problem Understanding Given a text string and a list of patterns, we need to: Find all substrings that match any pattern Wrap matching substrings in and tags Merge overlapping or adjacent bold regions Algorithm Steps The solution uses a boolean array to track which characters should be bold: ...

Read More

Program to find number of distinct coin sums we can make with coins and quantities in Python?

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

Suppose we have a list of values called coins and another list called quantities of the same length. The value of ith coin is coins[i] and we currently have quantities[i] number of ith coin. We have to find number of distinct coin sum values we can get by using non-empty group of these coins. So, if the input is like coins = [1, 2, 5] and quantities = [1, 2, 1], then the output will be 10, as we can have the following distinct coin sums: [1] = 1, [2] = 2, [1, 2] = 3, [2, 2] = ...

Read More

Program to find a pair (i, j) where nums[i] + nums[j] + (i -j) is maximized in Python?

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

Given a list of numbers, we need to find a pair (i, j) where i < j such that nums[i] + nums[j] + (i - j) is maximized. Since i < j, the term (i - j) will always be negative, so we're essentially looking for nums[i] + nums[j] - (j - i). For example, if nums = [6, 6, 2, 2, 2, 8], selecting indices i=0 and j=1 (both values are 6) gives us: 6 + 6 + (0 - 1) = 11. Algorithm Approach The key insight is to rearrange the expression nums[i] + nums[j] ...

Read More

Program to find length of longest diminishing word chain in Python?

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

Suppose we have a list of valid words and a string s. We need to find the length of the longest chain of diminishing words that can be generated by starting at s and removing single letters while keeping valid words. A diminishing word chain is formed by repeatedly removing one character from a word to create another valid word from the given list. Example If the input is words = ["lii", "limit", "limi", "li", "coffee", "jug", "pool", "type"] and s = "limit", the output will be 4. We can form the chain: "limit" → "limi" → ...

Read More

Program to print maximum number of characters by copy pasting in n steps in Python?

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

Suppose we have a number n; we have to find the maximum number of characters we can enter using n operations where each operation is like: Inserting the character "x". Copy all characters. Paste So, if the input is like n = 12, then the output will be 81. Understanding the Problem This is a dynamic programming problem where we need to find the optimal strategy to maximize characters. The key insight is that after typing some characters, we should copy-paste to multiply them efficiently. The pattern involves: Type characters individually when ...

Read More

Program to count minimum number of operations required to make numbers non coprime in Python?

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

Two numbers are coprime if their greatest common divisor (GCD) is 1. This program finds the minimum number of increment/decrement operations needed to make two numbers non-coprime (GCD > 1). Problem Understanding Given two numbers A and B, we can perform operations to increment or decrement either number by 1. The goal is to find the minimum operations required so that GCD(A, B) ≠ 1. Example If A = 8 and B = 9, we can increment B to 10. Then GCD(8, 10) = 2, which is not 1, so they become non-coprime in just 1 ...

Read More

Program to find next state of next cell matrix state in Python?

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

This problem implements Conway's Game of Life, where we need to find the next state of a 2D binary matrix. A cell's neighbors are its immediate horizontal, vertical and diagonal cells (8 neighbors total). The rules are: Any living cell with two or three living neighbors survives Any dead cell with exactly three living neighbors becomes alive All other cells die or remain dead Example Input and Output Given this input matrix − ...

Read More
Showing 501–510 of 3,768 articles
« Prev 1 49 50 51 52 53 377 Next »
Advertisements