Skip to content

Commit 6794e9d

Browse files
Merge pull request neetcode-gh#2815 from chetannada/ltc-2160-js
Create 2160-minimum-sum-of-four-digit-number-after-splitting-digits.js
2 parents f3b2304 + b2975c9 commit 6794e9d

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* @param {number} num
3+
* @return {number}
4+
*/
5+
var minimumSum = function (num) {
6+
let str = String(num).split("").sort(); // intialize str and split the num using String(), split() and sort()
7+
return parseInt(str[0] + str[2]) + parseInt(str[1] + str[3]); // return sum of 1st, 3rd and 2nd, 4th string digit and convert into num using parseInt
8+
};

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy