From db99fe1bae1a73f030bb3c5a00f04eca7ce07c3e Mon Sep 17 00:00:00 2001 From: Hao Chen Date: Fri, 29 Mar 2019 11:09:37 +0800 Subject: [PATCH] no tricky solution --- algorithms/cpp/twoSum/twoSum.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/algorithms/cpp/twoSum/twoSum.cpp b/algorithms/cpp/twoSum/twoSum.cpp index 6ef67fa77..dc0680f8a 100644 --- a/algorithms/cpp/twoSum/twoSum.cpp +++ b/algorithms/cpp/twoSum/twoSum.cpp @@ -66,4 +66,19 @@ class Solution { } return result; } + + // we also can store nums[i] into map, and find target - nums[i] + vector twoSum(vector& nums, int target) { + unordered_map m; + vector result; + for (int i=0; i