We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 39169ca commit 51f9247Copy full SHA for 51f9247
1 file changed
이용훈/9주차/260224.js
@@ -0,0 +1,21 @@
1
+/**
2
+ * @param {number[]} nums
3
+ * @return {number}
4
+ */
5
+var minimumCost = function(nums) {
6
+ let min1 = Number.MAX_SAFE_INTEGER;
7
+ let min2 = Number.MAX_SAFE_INTEGER;
8
+
9
+ for (let i = 1; i < nums.length; i++) {
10
+ const x = nums[i];
11
12
+ if (x < min1) {
13
+ min2 = min1;
14
+ min1 = x;
15
+ } else if (x < min2) {
16
+ min2 = x;
17
+ }
18
19
20
+ return nums[0] + min1 + min2;
21
+};
0 commit comments