diff --git a/srctwo-sum.cpp b/srctwo-sum.cpp new file mode 100644 index 0000000..0bbe904 --- /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