From 3da0d662a1d85765094c7d3e32ceb925164f1363 Mon Sep 17 00:00:00 2001 From: kutuzova-ann Date: Fri, 25 Apr 2025 22:35:50 +0500 Subject: [PATCH 1/2] Add files via upload added src/two-sum.cpp --- srctwo-sum.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 srctwo-sum.cpp diff --git a/srctwo-sum.cpp b/srctwo-sum.cpp new file mode 100644 index 0000000..8a3064e --- /dev/null +++ b/srctwo-sum.cpp @@ -0,0 +1,24 @@ +#include "two-sum.hpp" + +bool two-sum( + const int nums[ARRAY_SIZE], + const int target, + std::size_t& index0, + std::size_t& index1 +) + +{ + for(int i = 0; i < ARRAY_SIZE - 1;i++) + { + for(int j = i+1; j < ARRAY_SIZE; j++) + { + if(nums[i] + nums[j] == target) + { + index0 = i; + index1 = j; + return true; + } + } + } + return false; +}; \ No newline at end of file From 31135b4579db697e69f6a9f8385efa9bc0125e58 Mon Sep 17 00:00:00 2001 From: kutuzova-ann Date: Fri, 25 Apr 2025 22:52:13 +0500 Subject: [PATCH 2/2] Add files via upload added src/two-sum.cpp --- srctwo-sum.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srctwo-sum.cpp b/srctwo-sum.cpp index 8a3064e..0bbe904 100644 --- a/srctwo-sum.cpp +++ b/srctwo-sum.cpp @@ -1,6 +1,6 @@ #include "two-sum.hpp" -bool two-sum( +bool two_sum( const int nums[ARRAY_SIZE], const int target, std::size_t& index0,