Created
April 25, 2024 01:14
-
-
Save JunJaBoy/b47c96ff8e7f252f833b57fa2df0a6af to your computer and use it in GitHub Desktop.
HackerRate/Algorithm/MiniMaxSum kotlin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun miniMaxSum(arr: Array<Int>) { | |
val sorted = arr.map(Int::toLong).sorted() | |
println("${sorted.dropLast(1).sum()} ${sorted.drop(1).sum()}") | |
} | |
fun main(args: Array<String>) { | |
val arr = readln().trimEnd() | |
.split(" ") | |
.map { it.toInt() } | |
.toTypedArray() | |
miniMaxSum(arr) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment