From c85e9f791e745065634c4cfb1b40c5e4aab07d44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8E=AB=E5=AF=92=E6=B1=A0?= <13456287+mo-hanchi@user.noreply.gitee.com> Date: Tue, 19 Sep 2023 15:41:58 +0000 Subject: [PATCH] =?UTF-8?q?add=20=E4=B8=A4=E6=95=B0=E4=B9=8B=E5=92=8C.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 莫寒池 <13456287+mo-hanchi@user.noreply.gitee.com> --- "\344\270\244\346\225\260\344\271\213\345\222\214" | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 "\344\270\244\346\225\260\344\271\213\345\222\214" diff --git "a/\344\270\244\346\225\260\344\271\213\345\222\214" "b/\344\270\244\346\225\260\344\271\213\345\222\214" new file mode 100644 index 00000000..fb4d2bb2 --- /dev/null +++ "b/\344\270\244\346\225\260\344\271\213\345\222\214" @@ -0,0 +1,14 @@ +class Solution { +public: + vector twoSum(vector& nums, int target) { + int n = nums.size(); + for (int i = 0; i < n; ++i) { + for (int j = i + 1; j < n; ++j) { + if (nums[i] + nums[j] == target) { + return {i, j}; + } + } + } + return {}; + } +}; \ No newline at end of file -- Gitee