LeetCode-1. Two Sum

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.

Example:

The returned answers should be zero-based.

Solutions:

Brute Force 不值一提,本该用 HashTable 解决的问题在遇到了 Go 自带的 map 后就变得十分简单了,虽然写一个开地址哈希表也并不费事。

 

发表评论

电子邮件地址不会被公开。 必填项已用*标注