From 74d9f525ee2cb4ca995778d0f81367ebcebe79c2 Mon Sep 17 00:00:00 2001 From: tushar-ntiave Date: Fri, 18 Oct 2019 14:43:03 -0500 Subject: [PATCH] solution for twosum --- src/TwoSum/README.md | 9 +++++++++ src/TwoSum/Solution.cpp | 43 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 src/TwoSum/README.md create mode 100644 src/TwoSum/Solution.cpp diff --git a/src/TwoSum/README.md b/src/TwoSum/README.md new file mode 100644 index 0000000..8882c3a --- /dev/null +++ b/src/TwoSum/README.md @@ -0,0 +1,9 @@ +# Reverse Integer + +LeetCode [source](https://leetcode.com/problems/two-sum/) + +## AC Result + +| Status | Runtime | Memory | +|--------|---------|--------| +| Accepted | 364 ms | 9.3 MB | \ No newline at end of file diff --git a/src/TwoSum/Solution.cpp b/src/TwoSum/Solution.cpp new file mode 100644 index 0000000..0c1e2eb --- /dev/null +++ b/src/TwoSum/Solution.cpp @@ -0,0 +1,43 @@ +#include +#include +#include + +using namespace std; + +class Solution{ +public: + vector twoSum(vector nums, int target){ + + vector result; + int second_number; + + for(int i=0; i nums; + nums.push_back(3); + nums.push_back(2); + nums.push_back(4); + + int target = 6; + + vector result = s.twoSum(nums, target); + cout<