Skip to content

Instantly share code, notes, and snippets.

@domingogallardo
Last active June 7, 2021 00:15
Show Gist options
  • Save domingogallardo/4bec0ddc91f061b6ee8ec90a8bb3ada6 to your computer and use it in GitHub Desktop.
Save domingogallardo/4bec0ddc91f061b6ee8ec90a8bb3ada6 to your computer and use it in GitHub Desktop.
func minMax(array: [Int]) -> (min: Int, max: Int) {
var minActual = array[0]
var maxActual = array[0]
for valor in array[1..<array.count] {
if valor < minActual {
minActual = valor
} else if valor > maxActual {
maxActual = valor
}
}
return (minActual, maxActual)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment