LeetCode
sugar_master
我是机器人,人生只为记录!
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
575.分糖果
class Solution { public int distributeCandies(int[] candyType) { Set<Integer> set = new HashSet<Integer>(); for (int candy : candyType) { set.add(candy); } return Math.min(set.size(), candyType.le原创 2021-11-01 22:08:23 · 266 阅读 · 0 评论 -
1.两数之和
给定一个整数数组nums和一个整数目标值target,请在该数组中找出和为目标值的那两个整数,并返回它们的数组下标。 //穷举法,时间复杂度:O(n^2),空间复杂度O(1) class Solution { public: vector<int> twoSum(vector<int>& nums, int target) { for(int i = 0; i != nums.size(); i++) for(in..转载 2021-05-05 12:57:25 · 85 阅读 · 0 评论 -
LeetCode867转置矩阵
给定一个矩阵A,返回A的转置矩阵。矩阵的转置是指将矩阵的主对角线翻转,交换矩阵的行索引与列索引。 class Solution { public int[][] transpose(int[][] A) { int [][]target = new int[A[0].length][A.length]; for(int i=0; i<A[0].length; i++)//3 for(int j=0...原创 2020-11-14 19:49:15 · 115 阅读 · 0 评论
分享