LeetCode刷题笔记(1,两数之和,Easy)

Solution 1:哈希表 

执行时间:2ms

class Solution {
    public int[] twoSum(int[] nums, int target) {
        Map map = new HashMap< >();
        for(int i=0;i

Solution 2:暴力遍历法

执行时间:58ms

class Solution {
    public int[] twoSum(int[] nums, int target) {
        int[] index = new int[2];
        int i,j=0;
        for(i=0;i

 

你可能感兴趣的:(LeetCode刷题笔记(1,两数之和,Easy))