
Leetcode
文章平均质量分 56
Our destiny offers not the cup of despair, but the chalice of opportunity. So let us seize it, not in fear, but in gladness. -- R.M. Nixon
TYP_MOON
这个作者很懒,什么都没留下…
展开
-
94. Binary Tree Inorder Traversal(easy)
【代码】94. Binary Tree Inorder Traversal(easy)原创 2022-09-26 20:24:17 · 519 阅读 · 0 评论 -
1. 两数之和(Java)
给定一个整数数组 nums 和一个整数目标值 target,请你在该数组中找出 和为目标值 target 的那 两个 整数,并返回它们的数组下标。你可以假设每种输入只会对应一个答案。但是,数组中同一个元素在答案里不能重复出现。你可以按任意顺序返回答案。首先该题要求时间复杂度低于O(n^2),可以采用空间换时间的方法采用哈希表的方式。key为target与num[]中值之差,value为num[]中值的下标。检查哈希表中是否存在target与当前值之差:如果存在则返回该结果,如果不存在则将其存入哈希表原创 2022-01-19 13:27:29 · 168 阅读 · 0 评论 -
283. Move Zeroes(数组篇)
//Java方法一class Solution { public void moveZeroes(int[] nums) { if(nums==null) { return;//表示没有输出 } //定义两个指针i,j //j用来记录每个0的位置 int j = 0; //遍历整个数组 for(int i=0;i<nums.length;i++) { //如果当前值不为0 if(nums[i]!=0) { int temp = nums[i];/原创 2020-07-19 20:23:50 · 210 阅读 · 0 评论