All Posts

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 2744: Find Maximum Number of String Pairs

You are given a list of distinct strings words, where each string consists of exactly two lowercase English letters. You are tasked with finding the maximum number of pairs of strings that can be formed where one string is the reverse of the other.

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 2760: Longest Even Odd Subarray With Threshold

You are given a 0-indexed integer array ’nums’ and an integer ’threshold’. Find the length of the longest subarray of ’nums’ that satisfies the following conditions: (1) ’nums[l]’ is even, (2) the elements alternate between even and odd, and (3) all elements in the subarray are <= threshold.

Leetcode 2765: Longest Alternating Subarray

You are given a 0-indexed integer array ’nums’. A subarray ’s’ is called alternating if it follows a specific pattern of alternating differences between consecutive elements: +1, -1, +1, -1, and so on. Return the maximum length of all alternating subarrays, or -1 if no such subarray exists.

Leetcode 2769: Find the Maximum Achievable Number

Given two integers num and t, determine the maximum achievable number after performing at most t operations, where each operation allows simultaneous increments or decrements of num and the target number by 1.