Skip to content

Commit

Permalink
*
Browse files Browse the repository at this point in the history
  • Loading branch information
imteekay committed Nov 14, 2023
1 parent 3159c52 commit ba8531c
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// https://leetcode.com/problems/minimum-sum-of-mountain-triplets-i

function minimumSum(nums) {
let min = Infinity;

for (let i = 0; i < nums.length - 2; i++) {
for (let j = i + 1; j < nums.length - 1; j++) {
for (let k = j + 1; k < nums.length; k++) {
if (nums[i] < nums[j] && nums[k] < nums[j]) {
min = Math.min(min, nums[i] + nums[j] + nums[k]);
}
}
}
}

return min == Infinity ? -1 : min;
}

0 comments on commit ba8531c

Please sign in to comment.