All Posts

Leetcode 2652: Sum Multiples

Given a positive integer ’n’, find the sum of all integers between 1 and ’n’ (inclusive) that are divisible by 3, 5, or 7.

Leetcode 2654: Minimum Number of Operations to Make All Array Elements Equal to 1

You are given an array of positive integers ’nums’. You can perform an operation on this array where you select two consecutive elements and replace one of them with the gcd (greatest common divisor) of the two elements. The goal is to make all elements of the array equal to 1 using the minimum number of operations. If it’s impossible to make all elements equal to 1, return -1.

Leetcode 2729: Check if The Number is Fascinating

You are given a three-digit integer n. We define a number as fascinating if, when you concatenate n, 2 * n, and 3 * n, the resulting number contains all digits from 1 to 9 exactly once and does not contain any zeros.

Leetcode 2739: Total Distance Traveled

A truck has two fuel tanks, one main tank and one additional tank. The truck’s mileage is 10 km per liter, and fuel from the additional tank can be injected into the main tank after every 5 liters of fuel consumed. Your task is to calculate the maximum distance the truck can travel, considering both the main tank and the additional tank.

Leetcode 2748: Number of Beautiful Pairs

You are given an array ’nums’ containing integers. A pair of indices ‘i, j’ is considered beautiful if the first digit of nums[i] and the last digit of nums[j] are coprime. Two numbers are coprime if their greatest common divisor (GCD) is 1, i.e., ‘gcd(x, y) == 1’. Your task is to find the total number of beautiful pairs in nums.

Leetcode 2750: Ways to Split Array Into Good Subarrays

You are given a binary array ’nums’ containing only 0s and 1s. A good subarray is defined as a contiguous subarray that contains exactly one 1. Your task is to find the number of ways to split the array into good subarrays. Return the result modulo (10^9 + 7).