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.
var twoSum = function(nums, target) { var len = nums.length; var hash = {}; var i = 0; do { var a = nums[i]; var j = hash[a]; if (j !== undefined) { return [j, i ]; } else { hash[target - a] = i; } } while (++i < len); };