All Posts

Leetcode 2559: Count Vowel Strings in Ranges

Given an array of strings words and a list of queries, each query asks to count the number of strings in the specified range that start and end with a vowel. The vowels are ‘a’, ’e’, ‘i’, ‘o’, and ‘u’.

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.

Leetcode 2575: Find the Divisibility Array of a String

Given a string word consisting of digits and an integer m, return an array where each element is 1 if the numeric value of the prefix word[0,…,i] is divisible by m, otherwise 0.

Leetcode 2586: Count the Number of Vowel Strings in Range

You are given a 0-indexed integer array nums. You can rearrange the elements of nums to any order (including the given order). Define the prefix sum array of nums as prefix[i] = sum(nums[0] to nums[i]) after rearranging. The score of nums is the number of positive integers in the prefix array. Return the maximum score you can achieve by rearranging the elements of nums.

Leetcode 2606: Find the Substring With Maximum Cost

You are given a string s, a string chars of distinct characters, and an integer array vals of the same length as chars. The value of each character is determined by either its position in the alphabet or a corresponding value in the vals array if it is present in chars. The cost of a substring is the sum of the values of each character in that substring. Your goal is to find the maximum cost of any substring of s.

Leetcode 2609: Find the Longest Balanced Substring of a Binary String

You are given a binary string consisting of only ‘0’s and ‘1’s. A substring of this binary string is considered balanced if it contains equal numbers of ‘0’s and ‘1’s, and all the ‘0’s come before the ‘1’s. Your task is to find the length of the longest balanced substring.