Adding solutions in Swift for first 3 questions