2019-07-10
更新:
增加 Golang
1. Two Sum
❀ Origin
Problem
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, and you may not use the same element twice.
Example
1 | Given nums = [2, 7, 11, 15], target = 9, |
❀ 翻譯
問題
給定一個整數陣列, 回傳兩個數字的指數 indices
, 而這兩個數字相加必須等於目標數 target
.
假設每個輸入準確地只會有一組解, 且不能回傳同個數字兩次.
❀ Solution
JavaScript
1 | /** |
Golang
1 | func twoSum(nums []int, target int) []int { |