Arnab Chakraborty

Arnab Chakraborty

3,768 Articles Published

Articles by Arnab Chakraborty

Page 65 of 377

Check if it is possible to make two matrices strictly increasing by swapping corresponding values only in Python

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

Given two matrices of size n x m named mat1 and mat2, we need to check if both matrices can be made strictly increasing by swapping corresponding elements at position (i, j) between the matrices. A matrix is strictly increasing if each element is smaller than the element to its right and below it. Problem Understanding Consider these input matrices ? mat1 7 15 16 10 mat2 ...

Read More

Check if it is possible to get back to 12 O-clock only by adding or subtracting given seconds in Python

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

Suppose we have an array of n different second values. We have to check whether it is possible to start from 12 O'clock and go back to 12 by only adding or subtracting the given seconds or not. We can use all given seconds exactly once, we can either add seconds or subtract it. So, if the input is like seconds = [40, 90, 50], then the output will be True as we can add 40, then subtract 90, then again add 50 to get back to 12 O'clock. Algorithm To solve this, we will follow these ...

Read More

Check if it is possible to draw a straight line with the given direction cosines in Python

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

In 3D geometry, direction cosines represent the cosines of angles that a line makes with the coordinate axes. For a valid straight line, the sum of squares of direction cosines must equal 1. Direction cosines l, m, and n are defined as: l = cos(α), where α is the angle between the line and x-axis m = cos(β), where β is the angle between the line and y-axis n = cos(γ), where γ is the angle between the line and z-axis The fundamental property: l² + m² + n² = 1 Mathematical Foundation For ...

Read More

Check if it is possible to create a polygon with a given angle in Python

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

Suppose we have an angle a. We need to check whether we can create a regular polygon where all interior angles are equal to a. For example, if the input angle is 120°, the output will be True because a hexagon has all interior angles equal to 120°. Mathematical Formula The interior angle of a regular polygon is calculated using the formula ? Interior Angle (a) = (180 × (n-2)) / n where n = number of sides Therefore: n = 360 / (180 - a) If ...

Read More

Check if it is possible to create a polygon with given n sidess in Python

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

Suppose we have an array nums that contains the lengths of n sides. We have to check whether we can form a polygon with all of the given sides or not. So, if the input is like nums = [3, 4, 5], then the output will be True because there are three sides and sum of any two sides is larger than the 3rd one. To solve this, we will use the polygon inequality theorem where the length of the longest side must be smaller than the sum of all other sides. Algorithm To solve this, we ...

Read More

Check if it is possible to create a palindrome string from given N in Python

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

Suppose we have a number n. We have to check whether we can create an alphabetical lowercase string from that number and check whether the string is palindrome or not. Here we will take only characters from a to j, where a = 0, b = 1... j = 9. So if the number is 42, the substring "ec" will be repeated till we reach 6 (4+2) characters "ececec", then check if this is palindrome or not. So, if the input is like n = 43, then the output will be True. The string is "ededede" and this is ...

Read More

Check if it is possible to convert one string into another with given constraints in Python

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

Given two strings containing only characters 'A', 'B', and '#', we need to check if string s can be transformed into string t following these movement rules: 'A' can only move to the left 'B' can only move to the right 'A' and 'B' cannot cross each other '#' represents empty spaces Approach The solution involves validating that each character in s can move to its corresponding position in t without violating the movement constraints ? Algorithm Steps ...

Read More

Check if is possible to get given sum from a given set of elements in Python

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

Given an array of numbers and a target sum, we need to check if it's possible to achieve the target sum by adding elements from the array. Elements can be used multiple times. For example, with nums = [2, 3, 5] and sum = 28, the answer is True because we can get 28 using: 5 + 5 + 5 + 5 + 3 + 3 + 2 = 28. Approach We'll use dynamic programming with a boolean table to track all possible sums that can be formed ? Create a boolean table where table[i] ...

Read More

Check if given string can be split into four distinct strings in Python

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

Given a string, we need to check whether it can be split into four non-empty and distinct substrings. This problem involves finding all possible ways to partition the string into exactly four parts and verifying that all parts are unique. For example, if the input string is "helloworld", one valid split would be ["hel", "lo", "wor", "ld"] since all four substrings are distinct. Algorithm Approach The solution uses a brute force approach with three nested loops to generate all possible splits ? If the string length is ≥ 10, return True (optimization: with 10+ characters, ...

Read More

Check if given number is perfect square in Python

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

A perfect square is a number that can be expressed as the product of an integer with itself. In other words, a number is a perfect square when its square root is an integer. For example, 36 is a perfect square because √36 = 6, and 6 is an integer. In this tutorial, we'll explore different methods to check if a given number is a perfect square in Python. Algorithm To check if a number is a perfect square, we follow these steps ? Calculate the square root of the given number Take the integer ...

Read More
Showing 641–650 of 3,768 articles
« Prev 1 63 64 65 66 67 377 Next »
Advertisements