全站内容
medium
3297. Count Substrings That Can Be Rearranged to Contain a String I
#Problem You are given two strings word1 and word2. A string x is called valid if x can be rearranged to have word2 as a prefix. A prefix of a string is a substring that starts from the beginning of the string and extends to any point …
1186. Maximum Subarray Sum with One Deletion
#Problem Given an array of integers, return the maximum sum for a non-empty subarray (contiguous elements) with at most one element deletion. In other words, you want to choose a subarray and optionally delete one element from it so that …
1769. Minimum Number of Operations to Move All Balls to Each Box
#Problem You have n boxes. You are given a binary string boxes of length n, where boxes[i] is '0' if the iᵗʰ box is empty, and '1' if it contains one ball. In one operation, you can move one ball from a box to an adjacent box. Box i is …
2274. Maximum Consecutive Floors Without Special Floors
#Problem Alice manages a company and has rented some floors of a building as office space. Alice has decided some of these floors should be special floors, used for relaxation only. You are given two integers bottom and top, which denote …
2381. Shifting Letters II
#Problem You are given a string s of lowercase English letters and a 2D integer array shifts where shifts[i] = [startᵢ, endᵢ, directionᵢ]. For every i, shift the characters in s from the index startᵢ to the index endᵢ (inclusive) forward if …
848. Shifting Letters
#Problem You are given a string s of lowercase English letters and an integer array shifts of the same length. Call the shift() of a letter, the next letter in the alphabet, (wrapping around so that 'z' becomes 'a'). For example, shift('a') …
2241. Design an ATM Machine
#Problem There is an ATM machine that stores banknotes of 5 denominations: 20, 50, 100, 200, and 500 dollars. Initially the ATM is empty. The user can use the machine to deposit or withdraw any amount of money. When withdrawing, the machine …
1930. Unique Length-3 Palindromic Subsequences
#Problem Given a string s, return the number of unique palindromes of length three that are a subsequence of s. Note that even if there are multiple ways to obtain the same subsequence, it is still only counted once. A palindrome is a …
2270. Number of Ways to Split Array
#Problem You are given a 0-indexed integer array nums of length n. nums contains a valid split at index i if the following are true: The sum of the first i + 1 elements is greater than or equal to the sum of the last n - i - 1 elements. …
816. Ambiguous Coordinates
#Problem We had some 2-dimensional coordinates, like "(1, 3)" or "(2, 0.5)". Then, we removed all commas, decimal points, and spaces and ended up with the string s. For example, "(1, 3)" becomes s = "(13)" and "(2, 0.5)" becomes s = …