All Posts

Leetcode 2894: Divisible and Non-divisible Sums Difference

You are given two positive integers, n and m. Calculate the difference between the sum of integers in the range [1, n] that are not divisible by m (num1) and the sum of integers in the range [1, n] that are divisible by m (num2). Return the result of num1 - num2.

Leetcode 2899: Last Visited Integers

Given an integer array nums, where each element is either a positive integer or -1. For each -1, find the respective last visited positive integer. The ’last visited integer’ refers to the most recent positive integer seen before each -1.

Leetcode 2900: Longest Unequal Adjacent Groups Subsequence I

You are given two arrays: words (a list of distinct strings) and groups (a binary array where each element corresponds to an entry in words). Your task is to select the longest alternating subsequence of words, where each consecutive word has a different corresponding group value. For each pair of consecutive words in the subsequence, the corresponding values in groups must be different.

Leetcode 2903: Find Indices With Index and Value Difference I

You are given a 0-indexed array of integers nums of length n, along with two integers, indexDifference and valueDifference. Your task is to find two indices i and j such that the difference between the indices is greater than or equal to indexDifference, and the absolute difference between the values at the indices is greater than or equal to valueDifference. Return the indices [i, j] if such a pair exists, otherwise return [-1, -1].

Leetcode 2908: Minimum Sum of Mountain Triplets I

You are given an array of integers called nums. A mountain triplet consists of three indices (i, j, k) such that i < j < k, nums[i] < nums[j], and nums[k] < nums[j]. Your task is to return the minimum possible sum of any such mountain triplet. If no such triplet exists, return -1.

Leetcode 2913: Subarrays Distinct Element Sum of Squares I

You are given a 0-indexed integer array nums. A subarray of nums is a contiguous sequence of elements. The distinct count of a subarray is defined as the number of unique values within that subarray. Your task is to return the sum of the squares of the distinct counts for all possible subarrays of nums.