You are given an arraynumsof non-negative integers.numsis considered special if there exists a numberxsuch that there are exactlyxnumbers innumsthat are greater than or equal tox. Notice thatxdoes not have to be an element innums. Returnxif the array is special, otherwise, return-1. It ...
代码 classSolution:defspecialArray(self,nums:List[int])->int:forx inrange(len(nums)+1):count=0fori in nums:ifi>=x:count+=1ifcount>x:breakifcount==x:returnxreturn-1
You are given an array A of strings. A move onto S consists of swapping any two even indexed characters of S, or any two odd indexed characters of S. Two strings S and T are special-equivalent if after any number of moves onto S, S == T. For example, S = “zzxy” and T = ...
264、Ugly Number II (比较重要) 279、Perfect Squares 300、Longest Increasing Subsequence (比较重要) 53、max subarray Find the contiguous subarray within an array (containing at least one number) which has the largest sum. For example, given the array [-2,1,-3,4,-1,2,1,-5,4], the con...
特殊位置 定义:如果 mat[i][j] == 1 并且第 i 行和第 j 列中的所有其他元素均为 0(行和列的下标均 从 0 开始 ),则位置 (i, j) 被称为特殊位置。 来源:力扣(LeetCode) 链接:https://leetcode.cn/problems/special-positions-in-a-binary-matrix ...