We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1461e42 commit 4ee8a9eCopy full SHA for 4ee8a9e
1029-two-city-scheduling.js
@@ -24,6 +24,27 @@ const twoCitySchedCost = function(costs) {
24
25
// another
26
27
+/**
28
+ * @param {number[][]} costs
29
+ * @return {number}
30
+ */
31
+const twoCitySchedCost = function(costs) {
32
+ const N = costs.length
33
+ let res = 0
34
+ const refund = []
35
+ for(let i = 0; i < N; i++) {
36
+ refund[i] = costs[i][1] - costs[i][0]
37
+ res += costs[i][0]
38
+ }
39
+ refund.sort((a, b) => a - b)
40
+ for(let i = 0; i < N / 2; i++) {
41
+ res += refund[i]
42
43
+ return res
44
+};
45
+
46
+// another
47
48
/**
49
* @param {number[][]} costs
50
* @return {number}
0 commit comments