题目描述: 自己的提交: class Solution: def countSquares(self, matrix: List[List[int]]) -> int: if not matrix: return 0 m,n = len(matrix),len(matrix[0]) dp = [0] + [0] * m * n for i in range(m): for j in range(n): dp[i*n+j+1] = dp[i*n+j] layer = min(i,j) for l…
Give a string s, count the number of non-empty (contiguous) substrings that have the same number of 0's and 1's, and all the 0's and all the 1's in these substrings are grouped consecutively. Substrings that occur multiple times are counted the numbe…
题目大意 https://leetcode.com/problems/count-primes/description/ 204. Count Primes Count the number of prime numbers less than a non-negative number, n. Example: Input: 10Output: 4Explanation: There are 4 prime numbers less than 10, they are 2, 3, 5, 7.…
才一周没刷leetcode,手就生了,这个题目不难,但是完全AC还是挺费劲的. 题目描述: Compare two version numbers version1 and version2.If version1 > version2 return 1, if version1 < version2 return -1, otherwise return 0. You may assume that the version strings are non-empty and contain…
Compare two version numbers version1 and version1.If version1 > version2 return 1, if version1 < version2 return -1, otherwise return 0. You may assume that the version strings are non-empty and contain only digits and the . character.The . characte…