leetcode双人赛-Leetcode-train:Leetcode-火车

时间:2024-07-19 22:48:58
【文件属性】:

文件名称:leetcode双人赛-Leetcode-train:Leetcode-火车

文件大小:7KB

文件格式:ZIP

更新时间:2024-07-19 22:48:58

系统开源

leetcode双人赛Leetcode-火车 1. class Solution { public int[] twoSum(int[] nums, int target) { Map table = new HashMap<>(); for (int i = 0; i < nums.length; i++){ table.put(nums[i], i); } int [] result = new int[2]; for (int i = 0; i < nums.length; i++){ Integer a = table.get(target-nums[i]); if (a != null && (a != i)){ result[0] = i; result[1] = a; } } return result; } } 2. /** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x


【文件预览】:
Leetcode-train-master
----README.md(32KB)

网友评论