Created
June 9, 2019 20:27
-
-
Save shakyra/b561208380eb943b16a067bd70899f24 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 sumOfTwoSmallestIntegersIn(_ array: [Int]) -> Int { | |
let smallArray = array.sorted() | |
var firstNum = smallArray[0] | |
var secondNum = smallArray[1] | |
return firstNum + secondNum | |
} | |
sumOfTwoSmallestIntegersIn([19, 5, 42, 2, 77]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
func sumOfTwoSmallestIntegersIn(_ array: [Int]) -> Int {
let smallArray = array.sorted()
return smallArray[0] + smallArray[1]
}