Given an array of integers, return indices of the two numbers such that they add up to a specific target.
You may assume that each input would have exactly one solution.
Example:
Given nums = [2, 7, 11, 15], target = 9,
Because nums[0] + nums[1] = 2 + 7 = 9,
return [0, 1].
public class Solution {
public int[] twoSum(int[] nums, int target) {
int result[] = new int

该博客介绍了如何解决LeetCode上的1. Two Sum问题,即给定一个整数数组和一个目标值,找出数组中和为目标值的两个整数的索引。
订阅专栏 解锁全文
843

被折叠的 条评论
为什么被折叠?



