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

Making an Endless Runner in Godot, Parts 3 & 4 — Object Pool

Python — If, Elif, and Else Statement

WITH News Letter — March 2022

Before understanding what Istio is, let us start with the problem statement understanding.

The Dynamic Date Tile

How to deploy a React application on Patr

How to Develop a Cloud-based SaaS Application/ Software Product — Aalpha

*CUPOM DE 100% DE DESCONTO* — Google BigQuery e PostgreSQL: Big Query para análise de dados /…

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

Mockk for Java Mockito developers, an introduction

Learn Kotlin -Null Safety

TDD — Part III, Hilt and Robolectric (Android)

Dynamic Android Resources using Bash Scripting