From befcce767c33ed92d30e6203fd1e3af75a9b63f0 Mon Sep 17 00:00:00 2001 From: "Joon Yeol, Lee" Date: Mon, 14 Apr 2025 10:31:48 +0900 Subject: [PATCH] =?UTF-8?q?[Day16]=20=EC=9D=B4=EC=A4=80=EC=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../3427.cpp" | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 "leetcode2/1easy/\354\235\264\354\244\200\354\227\264/3427.cpp" diff --git "a/leetcode2/1easy/\354\235\264\354\244\200\354\227\264/3427.cpp" "b/leetcode2/1easy/\354\235\264\354\244\200\354\227\264/3427.cpp" new file mode 100644 index 00000000..989ee479 --- /dev/null +++ "b/leetcode2/1easy/\354\235\264\354\244\200\354\227\264/3427.cpp" @@ -0,0 +1,20 @@ +class Solution { + public: + int subarraySum(vector& nums) { + int output = 0; + + for (int i = 0; i < nums.size(); i++) + { + int tmp = 0; + for (int j = max(0, i - nums[i]); j <= i; j++) + { + tmp += nums[j]; + } + output += tmp; + } + + + return output; + + } + }; \ No newline at end of file