Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit a4df445

Browse files
committed
Add solution #1753
1 parent e721284 commit a4df445

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 1,520 LeetCode solutions in JavaScript
1+
# 1,521 LeetCode solutions in JavaScript
22

33
[https://leetcodejavascript.com](https://leetcodejavascript.com)
44

@@ -1350,6 +1350,7 @@
13501350
1750|[Minimum Length of String After Deleting Similar Ends](./solutions/1750-minimum-length-of-string-after-deleting-similar-ends.js)|Medium|
13511351
1751|[Maximum Number of Events That Can Be Attended II](./solutions/1751-maximum-number-of-events-that-can-be-attended-ii.js)|Hard|
13521352
1752|[Check if Array Is Sorted and Rotated](./solutions/1752-check-if-array-is-sorted-and-rotated.js)|Easy|
1353+
1753|[Maximum Score From Removing Stones](./solutions/1753-maximum-score-from-removing-stones.js)|Medium|
13531354
1764|[Form Array by Concatenating Subarrays of Another Array](./solutions/1764-form-array-by-concatenating-subarrays-of-another-array.js)|Medium|
13541355
1765|[Map of Highest Peak](./solutions/1765-map-of-highest-peak.js)|Medium|
13551356
1768|[Merge Strings Alternately](./solutions/1768-merge-strings-alternately.js)|Easy|
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/**
2+
* 1753. Maximum Score From Removing Stones
3+
* https://leetcode.com/problems/maximum-score-from-removing-stones/
4+
* Difficulty: Medium
5+
*
6+
* You are playing a solitaire game with three piles of stones of sizes a, b, and c respectively.
7+
* Each turn you choose two different non-empty piles, take one stone from each, and add 1 point
8+
* to your score. The game stops when there are fewer than two non-empty piles (meaning there are
9+
* no more available moves).
10+
*
11+
* Given three integers a, b, and c return the maximum score you can get.
12+
*/
13+
14+
/**
15+
* @param {number} a
16+
* @param {number} b
17+
* @param {number} c
18+
* @return {number}
19+
*/
20+
var maximumScore = function(a, b, c) {
21+
const piles = [a, b, c].sort((x, y) => y - x);
22+
let score = 0;
23+
24+
while (piles[0] > 0 && piles[1] > 0) {
25+
piles[0]--;
26+
piles[1]--;
27+
score++;
28+
piles.sort((x, y) => y - x);
29+
}
30+
31+
return score;
32+
};

0 commit comments

Comments
 (0)