All Posts
Leetcode 2531: Make Number of Distinct Characters Equal
word1
and word2
. In each move, you swap one character from word1
with one from word2
. Determine if it is possible to make the number of distinct characters in both strings equal with exactly one swap.
You are given two strings, Leetcode 2537: Count the Number of Good Subarrays
nums
and an integer k
, return the number of “good” subarrays. A subarray is good if it contains at least k
pairs of indices (i, j)
such that i < j
and nums[i] == nums[j]
. A subarray is a contiguous non-empty sequence of elements within the array.
Given an integer array Leetcode 2540: Minimum Common Value
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
.
Given two integer arrays Leetcode 2549: Count Distinct Numbers on Board
n
, initially placed on a board. For each number x
on the board, find all integers i
such that 1 <= i <= n
and x % i == 1
. Add these numbers to the board. Your goal is to determine how many distinct integers will be present on the board after a billion days.
You are given a positive integer Leetcode 2554: Maximum Number of Integers to Choose From a Range I
banned
consisting of integers, an integer n
, and an integer maxSum
. Your task is to return the maximum number of integers you can select from the range [1, n] such that none of them are in the banned
list and their sum does not exceed maxSum
.
You are given an array Leetcode 2564: Substring XOR Queries
You are given a binary string s
and a 2D array of queries. Each query is represented as [firsti, secondi], where firsti
and secondi
are integers. For each query, you need to find the shortest substring of s
whose decimal value XORed with firsti
equals secondi
.
In other words, find a substring whose decimal value, when XORed with firsti
, results in secondi
. If such a substring exists, return its starting and ending indices (0-indexed). If no such substring exists, return [-1, -1].
If there are multiple valid substrings, return the one with the smallest starting index.