From cdb5d358cfcdb17718acea89f7729d6adfc412d2 Mon Sep 17 00:00:00 2001 From: Jinyoung Jeong <80400463+jyoung2419@users.noreply.github.com> Date: Fri, 4 Sep 2026 22:06:50 +0900 Subject: [PATCH] Add maxDigitRange function for digit range sum Implement function to calculate sum of integers with maximum digit range. --- ... Sum of Integers with Maximum Digit Range" | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 "leetcode3/\354\240\225\354\247\204\354\230\201/3982. Sum of Integers with Maximum Digit Range" diff --git "a/leetcode3/\354\240\225\354\247\204\354\230\201/3982. Sum of Integers with Maximum Digit Range" "b/leetcode3/\354\240\225\354\247\204\354\230\201/3982. Sum of Integers with Maximum Digit Range" new file mode 100644 index 00000000..4b6f4640 --- /dev/null +++ "b/leetcode3/\354\240\225\354\247\204\354\230\201/3982. Sum of Integers with Maximum Digit Range" @@ -0,0 +1,22 @@ +/** + * @param {number[]} nums + * @return {number} + */ +var maxDigitRange = function(nums) { + let sum = 0; + let maxRange = -1; + for (let i = 0; i a-b); // 2 4 5 7 + + const range = arr[arr.length - 1] - arr[0]; + + if (range > maxRange){ + maxRange = range; + sum = nums[i]; + } else if (range == maxRange){ + sum += nums[i]; + } + } + return sum; +};