Arnab Chakraborty

Arnab Chakraborty

3,768 Articles Published

Articles by Arnab Chakraborty

Page 145 of 377

Largest Triangle Area in Python

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

Given a list of points on a plane, we need to find the area of the largest triangle that can be formed by any 3 of the points. This problem requires checking all possible combinations of three points and calculating their triangle areas. So, if the input is like [[0, 0], [0, 1], [1, 0], [0, 2], [2, 0]], then the output will be 2.0 ...

Read More

Number of Lines To Write String in Python

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

When writing a string onto lines with a maximum width of 100 units, we need to determine how many lines are required and the width used by the last line. Each character has a specific width given in a widths array where widths[0] represents the width of 'a', widths[1] represents 'b', and so on. The problem asks us to find ? How many lines have at least one character from the string What is the width used by the last line Algorithm We follow these steps ? Initialize lines = 1 and ...

Read More

Unique Morse Code Words in Python

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

In this problem, we need to find how many unique Morse code representations exist for a given list of words. Each letter maps to a specific Morse code pattern, and words with the same Morse code transformation are considered identical. The International Morse Code defines a standard encoding where each letter is mapped to a series of dots and dashes. For example, "a" maps to ".-", "b" maps to "-...", "c" maps to "-.-.", and so on. Morse Code Mapping Here is the complete list of Morse code patterns for all 26 letters ? morse_codes ...

Read More

Prime Number of Set Bits in Binary Representation in Python

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

Suppose we have two integers L and R, we have to find the count of numbers in the range [L, R] (inclusive) having a prime number of set bits in their binary form. So, if the input is like L = 6 and R = 10, then the output will be 4, as there are 4 numbers 6(110), 7(111), 9(1001), 10(1010), all have prime number of set bits. Understanding Set Bits Set bits are the bits that are '1' in the binary representation of a number. For example: 6 in binary is 110, which has ...

Read More

Shortest Completing Word in Python

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

The Shortest Completing Word problem requires finding the shortest word from a dictionary that contains all letters from a given license plate. The word must include each letter at least as many times as it appears in the license plate, ignoring case and non-alphabetic characters. For example, if the license plate is "PP", the word "pile" doesn't work because it only has one 'P', but "topper" works because it has two 'P's. Problem Understanding Given a license plate string and a list of words, we need to: Extract only alphabetic characters from the license plate ...

Read More

Largest Number At Least Twice of Others in Python

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

Given an integer array nums, we need to check whether the largest element is at least twice as large as every other number in the array. If it satisfies this condition, return the index of the largest element, otherwise return -1. So, if the input is like [3, 6, 1, 0], then the output will be 1, as 6 is the largest number, and for every other number in the array x, 6 is more than twice as big as x. Since the index of 6 is 1, the output is 1. Algorithm To solve this problem, ...

Read More

Min Cost Climbing Stairs in Python

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

The min cost climbing stairs problem is a classic dynamic programming challenge. Given a staircase where each step has a cost, we need to find the minimum cost to reach the top. We can start from either step 0 or step 1, and from any step we can climb either one or two steps forward. For example, if we have cost = [12, 17, 20], the minimum cost is 17. We start from step 1 (cost 17) and climb two steps to reach the top, avoiding the higher costs of steps 0 and 2. Algorithm Steps We ...

Read More

Find Smallest Letter Greater Than Target in Python

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

Given a sorted list of lowercase letters, we need to find the smallest letter that is greater than a target letter. The letters wrap around, so if no letter is greater than the target, we return the first letter in the list. For example, if we have letters ["c", "f", "j"] and target "a", the answer is "c". If the target is "z" and letters are ["a", "b"], the answer wraps around to "a". Using Binary Search Since the letters are already sorted, we can use binary search to find the smallest letter greater than the target ...

Read More

Longest Word in Dictionary in Python

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

Finding the longest word in a dictionary that can be built one character at a time is a classic problem that can be solved efficiently using a Trie (Prefix Tree) data structure. The goal is to find the longest word where each prefix also exists in the dictionary. For example, given the dictionary ["h", "he", "hel", "hell", "hello"], the word "hello" can be built step by step since "h", "he", "hel", and "hell" all exist in the dictionary. Algorithm Overview The solution uses a Trie to store all words and then checks if each word can be ...

Read More

Design HashMap in Python

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

A HashMap is a key-value data structure that provides fast lookups, insertions, and deletions. We can implement a custom HashMap in Python using an array of linked lists to handle collisions through chaining. HashMap Operations Our HashMap will support three main operations ? put(key, value) − Insert or update a key-value pair get(key) − Retrieve the value for a given key, return -1 if not found remove(key) − Delete a key-value pair from the HashMap Implementation Strategy We'll use separate chaining to handle hash collisions. Each bucket in our hash table contains a ...

Read More
Showing 1441–1450 of 3,768 articles
« Prev 1 143 144 145 146 147 377 Next »
Advertisements