Created
November 19, 2020 19:00
-
-
Save niharika2810/b120446b81784b309c6ebac61321bf18 to your computer and use it in GitHub Desktop.
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
private const val MIN = -1private const val MAX = -1 | |
fun getMinAndMax(numberString: String): String = | |
numberString.split(' ') | |
.mapNotNull { stringItem -> stringItem.toIntOrNull() } | |
.distinct() | |
.let { numbersList -> "${numbersList.maxOrNull() ?: MAX} ${numbersList.minOrNull() ?: MIN}" } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment