本文共 800 字,大约阅读时间需要 2 分钟。
Given an array of integers nums and an integer target,return indices of the two numbers such that they add up to target.You may assume that each input would have exactly one solution,and you may not use the same element twice. You can return the answer in any order.
public static int [] TowNumberSum_1(int []nums,int target) { for(int i=0;i
public static int[] TowNumberSum_2(int [] nums,int target) { Mapmap=new HashMap<>(); for(int i=0;i
package leetcode;import java.util.Arrays;import java.util.HashMap;import java.util.Map;public class TowSum { //暴力法 /* public static int [] TowNumberSum_1(int []nums,int target) { for(int i=0;imap=new HashMap<>(); for(int i=0;i
转载地址:http://yyhdi.baihongyu.com/