uacs2024

导航

上一页 1 2 3 4 5 6 ··· 26 下一页

2025年11月13日 #

leetcode6. Z 字形变换

摘要: 6. Z 字形变换 法一:一开始自己写的史山代码. class Solution { public String convert(String s, int numRows) { if(numRows == 1) return s; ArrayList<char[]> zConvert = new 阅读全文

posted @ 2025-11-13 22:31 ᶜʸᵃⁿ 阅读(7) 评论(0) 推荐(0)

leetcode73. 矩阵置零

摘要: 73. 矩阵置零 法一:和零的数量相关的额外数组 202209写的c++代码 class Solution { public: void setZeroes(vector<vector<int>>& matrix) { int size1=matrix.size(),size2=matrix[0]. 阅读全文

posted @ 2025-11-13 15:04 ᶜʸᵃⁿ 阅读(4) 评论(0) 推荐(0)

2025年11月11日 #

leetcode289. 生命游戏

摘要: 289. 生命游戏 注意,更新要基于原状态更新,不是基于新状态的部分更新 法一:额外数组。对于边界,全部视为0。第一次通过的代码。 class Solution { public void gameOfLife(int[][] board) { int m = board.length,n = bo 阅读全文

posted @ 2025-11-11 22:06 ᶜʸᵃⁿ 阅读(5) 评论(0) 推荐(0)

2025年11月3日 #

leetcode55. 跳跃游戏 45. 跳跃游戏 II

摘要: 55. 跳跃游戏 45. 跳跃游戏 II 法一:我写的第一份通过的代码,问题在于重复更新浪费不少时间,内层循环可能会重复更新许多已经确定不是最优解的位置。 class Solution { public int jump(int[] nums) { int n = nums.length; int[ 阅读全文

posted @ 2025-11-03 21:31 ᶜʸᵃⁿ 阅读(10) 评论(0) 推荐(0)

13. 罗马数字转整数

摘要: 13. 罗马数字转整数 我写的原始代码,不够优雅。 class Solution { public int romanToInt(String s) { char[] sChar = s.toCharArray(); int res = 0,n = s.length(); HashMap<Chara 阅读全文

posted @ 2025-11-03 17:13 ᶜʸᵃⁿ 阅读(9) 评论(0) 推荐(0)

2025年10月31日 #

leetcode274. H 指数

摘要: 274. H 指数 自己写的先排序后反向遍历 class Solution { public int hIndex(int[] citations) { int n = citations.length; Arrays.sort(citations); if(citations[0] >= n) r 阅读全文

posted @ 2025-10-31 14:33 ᶜʸᵃⁿ 阅读(6) 评论(0) 推荐(0)

2025年10月28日 #

leetcode88. 合并两个有序数组

摘要: 88. 合并两个有序数组 法一:第一时间想到的额外空间 class Solution { public void merge(int[] nums1, int m, int[] nums2, int n) { int i = 0,j = 0; int[] res = new int[m + n]; 阅读全文

posted @ 2025-10-28 22:06 ᶜʸᵃⁿ 阅读(10) 评论(0) 推荐(0)

2025年10月23日 #

leetcode1. 两数之和、15. 三数之和、18. 四数之和

摘要: 1. 两数之和 注意,这个要返回的是对应数字的下标。 2022/09的C++代码 class Solution { public: vector<int> twoSum(vector<int>& nums, int target) { int size=nums.size(); unordered_ 阅读全文

posted @ 2025-10-23 22:06 ᶜʸᵃⁿ 阅读(7) 评论(0) 推荐(0)

2025年10月22日 #

leetcode477. 汉明距离总和

摘要: 477. 汉明距离总和 🤡过不了的暴力解: class Solution { public int totalHammingDistance(int[] nums) { int n = nums.length,res = 0; for(int i = 0;i < n;++i){ for(int j 阅读全文

posted @ 2025-10-22 20:36 ᶜʸᵃⁿ 阅读(5) 评论(0) 推荐(0)

2025年10月21日 #

leetcode448. 找到所有数组中消失的数字

摘要: 448. 找到所有数组中消失的数字 我的解法:额外数组 class Solution { public List<Integer> findDisappearedNumbers(int[] nums) { int n = nums.length; boolean[] flag = new boole 阅读全文

posted @ 2025-10-21 19:14 ᶜʸᵃⁿ 阅读(5) 评论(0) 推荐(0)

上一页 1 2 3 4 5 6 ··· 26 下一页