All Posts

Leetcode 1685: Sum of Absolute Differences in a Sorted Array

You are given a sorted integer array nums. Build and return an integer array result such that for each index i, result[i] is equal to the summation of absolute differences between nums[i] and all other elements in the array.

Leetcode 1712: Ways to Split Array Into Three Subarrays

You are given an array of non-negative integers. Your task is to count the number of ways the array can be split into three contiguous non-empty subarrays: left, mid, and right. The sum of the elements in the left subarray should be less than or equal to the sum in the mid subarray, and the sum of the mid subarray should be less than or equal to the sum of the right subarray. Return the number of such good splits modulo 10^9 + 7.

Leetcode 1732: Find the Highest Altitude

A biker is going on a road trip, where the trip consists of several points with different altitudes. The biker starts at point 0, which has an altitude of 0. You are given an array of integers gain, where each value represents the change in altitude between two consecutive points. Your task is to find the highest altitude the biker reaches during the trip.

Leetcode 1737: Change Minimum Characters to Satisfy One of Three Conditions

You are given two strings, a and b, consisting of lowercase letters. In one operation, you can change any character in either string to any lowercase letter. Your goal is to perform the minimum number of operations to satisfy one of the following three conditions:

  1. Every character in string a is strictly less than every character in string b alphabetically.
  2. Every character in string b is strictly less than every character in string a alphabetically.
  3. Both a and b consist of only one distinct character.

Return the minimum number of operations needed to achieve one of these conditions.

Leetcode 1738: Find Kth Largest XOR Coordinate Value

You are given a 2D matrix of size m x n, consisting of non-negative integers. You are also given an integer k. The value of coordinate (a, b) in the matrix is the XOR of all the values from matrix[0][0] to matrix[a][b] (inclusive), where 0 <= a < m and 0 <= b < n (0-indexed). Your task is to find the kth largest value (1-indexed) among all the XOR values of matrix coordinates.

Leetcode 1744: Can You Eat Your Favorite Candy on Your Favorite Day?

You are given an array candiesCount where each element represents the number of candies of a particular type. You are also given a set of queries, each asking whether it’s possible to eat a candy of a certain type on a specific day without exceeding a daily candy limit. You must follow these game rules:

  • You start eating candies on day 0.
  • You cannot eat candies of type i until you have eaten all candies of type i-1.
  • You must eat at least one candy per day.

Your task is to return an array of booleans where each element indicates whether it’s possible to eat a candy of the specified type on the given day, subject to the daily cap.