LeetCodeTop100

Picasun ECNU_Jinggg

哎呀 我怎么在刷算法 刷吧

Easy

Day1:两数之和

1
2
3
4
5
6
7
8
9
10
11
12
13
class Solution {
public int[] twoSum(int[] nums, int target) {
int length=nums.length;//length function
for(int i=0;i<length;i++){
for(int j=i+1;j<length;j++){
if(nums[i]+nums[j]==target){
return new int[]{i,j};//new a array to return
}
}
}
return new int[]{}; //must have return
}
}

Medium

Hard

  • Post title:LeetCodeTop100
  • Post author:Picasun
  • Create time:2025-04-21 22:26:46
  • Post link:https://redefine.ohevan.com/2025/04/21/LeetCodeTop100/
  • Copyright Notice:All articles in this blog are licensed under BY-NC-SA unless stating additionally.
Advertising space for rent :)
LeetCodeTop100