Last active
June 7, 2021 00:15
-
-
Save domingogallardo/4bec0ddc91f061b6ee8ec90a8bb3ada6 to your computer and use it in GitHub Desktop.
This file contains 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
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