Skip to content

Instantly share code, notes, and snippets.

@niharika2810
Created November 19, 2020 19:00
Show Gist options
  • Save niharika2810/b120446b81784b309c6ebac61321bf18 to your computer and use it in GitHub Desktop.
Save niharika2810/b120446b81784b309c6ebac61321bf18 to your computer and use it in GitHub Desktop.
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