Mini-Max Sum Solution in Kotlin -HackerRank

16 24
1 < arr[i] < 10
1 2 3 4 5
10 14
fun miniMaxSum(arr: Array<Int>): Unit {    var min:Long =  arr[0].toLong()
var max:Long = 0
var total:Long = 0
for (x in 0 until arr.size) {
val item = arr[x].toLong()
total += item
if (item < min) {
min = item
}
if (item > max) {
max = item
}
}
println("${total - max} ${total - min}")}

--

--

--

Hey curious person, I am Software Developer

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

The Riot Act

CSS: Day 27

Rotating a div with pink background to 180 deg

CS373 Fall 2020: Elias Lampietti

Why donations are important

CSS Overview + Block/Inline

Updating encryption key of a secret in AWS Secrets Manager gone wrong

8×8 Reviewed

Creating a dynamic paragraphs sidebar with JS and jQuery

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Umar Syaid Himawan

Umar Syaid Himawan

Hey curious person, I am Software Developer

More from Medium

Coroutine Adventure Part.4

Ideas and Solutions for Advent of Code 2021 in Kotlin — Part 3/4

Testing Dialogs in Robolectric

Binary Tree Traversal Algorithms in Kotlin