全站内容
medium
1338. Reduce Array Size to The Half
#Problem You are given an integer array arr. You can choose a set of integers and remove all the occurrences of these integers in the array. Return the minimum size of the set so that at least half of the integers of the array are removed. …
2762. Continuous Subarrays
#Problem You are given a 0-indexed integer array nums. A subarray of nums is called continuous if: Let i, i + 1, …, j be the indices in the subarray. Then, for each pair of indices i <= i₁, i₂ <= j, 0 <= |nums[i₁] - nums[i₂]| <= 2. Return …
2593. Find Score of an Array After Marking All Elements
#Problem You are given an array nums consisting of positive integers. Starting with score = 0, apply the following algorithm: Choose the smallest integer of the array that is not marked. If there is a tie, choose the one with the smallest …
2779. Maximum Beauty of an Array After Applying Operation
#Problem You are given a 0-indexed array nums and a non-negative integer k. In one operation, you can do the following: Choose an index i that hasn’t been chosen before from the range [0, nums.length - 1]. Replace nums[i] with any integer …
2982. Find Longest Special Substring That Occurs Thrice II
跟 2981. Find Longest Special Substring That Occurs Thrice I 一模一样,只不过 s 的长度上限从 50 增加到 5 * 10⁵。 https://leetcode.com/problems/find-longest-special-substring-that-occurs-thrice-ii/ 直接用上次的代码没问题。
2981. Find Longest Special Substring That Occurs Thrice I
#Problem You are given a string s that consists of lowercase English letters. A string is called special if it is made up of only a single character. For example, the string "abc" is not special, whereas the strings "ddd", "zz", and "f" are …
935. Knight Dialer
#Problem The chess knight has a unique movement, it may move two squares vertically and one square horizontally, or two squares horizontally and one square vertically (with both forming the shape of an L). The possible movements of chess …
954. Array of Doubled Pairs
#Problem Given an integer array of even length arr, return true if it is possible to reorder arr such that arr[2 * i + 1] = 2 * arr[2 * i] for every 0 <= i < len(arr) / 2, or false otherwise. …
2. Add Two Numbers
#Problem You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list. You …
3152. Special Array II
#Problem An array is considered special if every pair of its adjacent elements contains two numbers with different parity. You are given an array of integer nums and a 2D integer matrix queries, where for queries[i] = [fromᵢ, toᵢ] your task …