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

Commit 4ac50a7

Browse files
committed
Add solution #2160
1 parent d2ea5b5 commit 4ac50a7

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-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,783 LeetCode solutions in JavaScript
1+
# 1,784 LeetCode solutions in JavaScript
22

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

@@ -1653,6 +1653,7 @@
16531653
2155|[All Divisions With the Highest Score of a Binary Array](./solutions/2155-all-divisions-with-the-highest-score-of-a-binary-array.js)|Medium|
16541654
2156|[Find Substring With Given Hash Value](./solutions/2156-find-substring-with-given-hash-value.js)|Hard|
16551655
2157|[Groups of Strings](./solutions/2157-groups-of-strings.js)|Hard|
1656+
2160|[Minimum Sum of Four Digit Number After Splitting Digits](./solutions/2160-minimum-sum-of-four-digit-number-after-splitting-digits.js)|Easy|
16561657
2161|[Partition Array According to Given Pivot](./solutions/2161-partition-array-according-to-given-pivot.js)|Medium|
16571658
2176|[Count Equal and Divisible Pairs in an Array](./solutions/2176-count-equal-and-divisible-pairs-in-an-array.js)|Easy|
16581659
2179|[Count Good Triplets in an Array](./solutions/2179-count-good-triplets-in-an-array.js)|Hard|
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* 2160. Minimum Sum of Four Digit Number After Splitting Digits
3+
* https://leetcode.com/problems/minimum-sum-of-four-digit-number-after-splitting-digits/
4+
* Difficulty: Easy
5+
*
6+
* You are given a positive integer num consisting of exactly four digits. Split num into two
7+
* new integers new1 and new2 by using the digits found in num. Leading zeros are allowed in
8+
* new1 and new2, and all the digits found in num must be used.
9+
* - For example, given num = 2932, you have the following digits: two 2's, one 9 and one 3.
10+
* Some of the possible pairs [new1, new2] are [22, 93], [23, 92], [223, 9] and [2, 329].
11+
*
12+
* Return the minimum possible sum of new1 and new2.
13+
*/
14+
15+
/**
16+
* @param {number} num
17+
* @return {number}
18+
*/
19+
var minimumSum = function(num) {
20+
const digits = String(num).split('').map(Number).sort((a, b) => a - b);
21+
return (digits[0] * 10 + digits[2]) + (digits[1] * 10 + digits[3]);
22+
};

0 commit comments

Comments
 (0)