![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
leetcode
zgMelia
这个作者很懒,什么都没留下…
展开
-
LeetCode 461.汉明距离
两个整数之间的汉明距离指的是这两个数字对应二进制位不同的位置的数目。给出两个整数 x 和 y,计算它们之间的汉明距离。注意:0 ≤ x, y < 231.我一直都觉得我自己写python一股c味儿############################################import mathclass Solution: def hammingDistance(sel...转载 2018-05-03 18:57:22 · 125 阅读 · 0 评论 -
Leetcode 766. 托普利茨矩阵
如果一个矩阵的每一方向由左上到右下的对角线上具有相同元素,那么这个矩阵是托普利茨矩阵。给定一个 M x N 的矩阵,当且仅当它是托普利茨矩阵时返回 True。示例 1:输入: matrix = [[1,2,3,4],[5,1,2,3],[9,5,1,2]]输出: True解释:123451239512在上面这个矩阵中, 对角线分别是 "[9]", "[5, 5]", "[1, 1, ...原创 2018-05-04 20:03:48 · 175 阅读 · 0 评论 -
LeetCode 566. 重塑矩阵
在MATLAB中,有一个非常有用的函数 reshape,它可以将一个矩阵重塑为另一个大小不同的新矩阵,但保留其原始数据。给出一个由二维数组表示的矩阵,以及两个正整数r和c,分别表示想要的重构的矩阵的行数和列数。重构后的矩阵需要将原始矩阵的所有元素以相同的行遍历顺序填充。如果具有给定参数的reshape操作是可行且合理的,则输出新的重塑矩阵;否则,输出原始矩阵。示例 1:输入: nums = [...原创 2018-05-04 21:33:35 · 105 阅读 · 0 评论 -
leetcode:Perfect Squares -----BFS
Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, ...) which sum to n.Example 1:Input: n = 12Output: 3 Explanation: 12 = 4 + 4 + 4.Example...原创 2019-01-06 11:17:55 · 138 阅读 · 0 评论 -
leetcode :Valid Parentheses
Valid Parentheses Go to DiscussGiven a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.An input string is valid if:Open brackets ...原创 2019-01-07 16:59:38 · 165 阅读 · 0 评论