Passion and Patience

Work Hard, Play Hard

导航

2024年3月21日 #

Leetcode 只出现一次的数据

摘要: Day 7 第三题 我的思路:利用Stream 的distinct()方法找出不重复的,但后续思路想不出来。 class Solution { public int singleNumber(int[] nums) { int n = nums.length; IntStream stream = 阅读全文

posted @ 2024-03-21 23:24 安静的聆 阅读(8) 评论(0) 推荐(0)

Leecode 杨辉三角Ⅱ

摘要: Day 7 第二题 我的思路和上一篇的杨辉三角一致,只不过将List获取层数的代码List.get(0).add()修改成数组 class Solution { public List<Integer> getRow(int rowIndex) { List<Integer> getRow = ne 阅读全文

posted @ 2024-03-21 16:37 安静的聆 阅读(14) 评论(0) 推荐(0)

Leecode 杨辉三角

摘要: Day 7 刷题 我的解题思路:按照杨辉三角的生成原理,行列交替循环。本方法消耗的空间复杂度和时间复杂度都很大,因为使用list操作获取上一层信息!此外需要学习建立list层的方法:list.add(new LinkedList<>()). class Solution { public List< 阅读全文

posted @ 2024-03-21 13:01 安静的聆 阅读(18) 评论(0) 推荐(0)