All Posts
Leetcode 2465: Number of Distinct Averages
You are given an array of even length containing integers. In each step, repeatedly remove the smallest and the largest numbers from the array, calculate their average, and continue until the array is empty. The goal is to find how many distinct averages were calculated during this process.
Leetcode 2486: Append Characters to String to Make Subsequence
You are given two strings, s and t, consisting only of lowercase English letters. Your task is to determine the minimum number of characters that need to be appended to the end of string s so that string t becomes a subsequence of s. A subsequence is a string that can be derived from another string by deleting some or no characters without changing the order of the remaining characters.
Leetcode 2491: Divide Players Into Teams of Equal Skill
You are given an array of integers representing the skill levels of players. You need to divide the players into pairs such that the sum of the skill levels of each pair is the same across all pairs. If it’s possible to form such pairs, return the sum of their chemistry, which is the product of the skill levels in each pair. If no such division is possible, return -1.
Leetcode 2511: Maximum Enemy Forts That Can Be Captured
You are given a 0-indexed integer array forts representing the positions of several forts. Your goal is to move your army from one of your forts to an empty position and capture enemy forts along the way. The army captures all enemy forts that lie between the starting and destination points, and you want to maximize the number of enemy forts captured.
Leetcode 2540: Minimum Common Value
Given two integer arrays nums1 and nums2 sorted in non-decreasing order, return the smallest integer that is common to both arrays. If no such integer exists, return -1.
Leetcode 2562: Find the Array Concatenation Value
You are given an array of integers, nums, and you need to calculate the total concatenation value. To calculate this, you repeatedly perform the following operations until the array is empty:
- If the array has more than one element, take the first and last elements, concatenate them, and add the result to the total concatenation value. Then remove the first and last elements from the array.
- If the array has only one element, add it to the total concatenation value and remove the element.
The goal is to return the total concatenation value after performing all the operations.