Skip to content

Instantly share code, notes, and snippets.

@shakyra
Created June 9, 2019 20:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shakyra/b561208380eb943b16a067bd70899f24 to your computer and use it in GitHub Desktop.
Save shakyra/b561208380eb943b16a067bd70899f24 to your computer and use it in GitHub Desktop.
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])
@shakyra
Copy link
Author

shakyra commented Jun 9, 2019

func sumOfTwoSmallestIntegersIn(_ array: [Int]) -> Int {
let smallArray = array.sorted()
return smallArray[0] + smallArray[1]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment