From 929476174ce8dcde2f22f413cffbb81511be1d45 Mon Sep 17 00:00:00 2001 From: GinGong <15754191+gingong@user.noreply.gitee.com> Date: Tue, 16 Sep 2025 04:04:30 +0000 Subject: [PATCH] =?UTF-8?q?add=20exercise/LC0001=5F=E9=BE=9A=E7=82=9C?= =?UTF-8?q?=E6=9D=B0.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: GinGong <15754191+gingong@user.noreply.gitee.com> --- ...0001_\351\276\232\347\202\234\346\235\260" | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 "exercise/LC0001_\351\276\232\347\202\234\346\235\260" diff --git "a/exercise/LC0001_\351\276\232\347\202\234\346\235\260" "b/exercise/LC0001_\351\276\232\347\202\234\346\235\260" new file mode 100644 index 0000000..88fbb87 --- /dev/null +++ "b/exercise/LC0001_\351\276\232\347\202\234\346\235\260" @@ -0,0 +1,21 @@ +#include +using namespace std; + +// 【题目】力扣001. 两数之和 +// 【难度】简单 +// 【提交】https://leetcode.cn/problems/two-sum/submissions/663172129 +// 【标签】数组;哈希表 +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