Skip to content

Instantly share code, notes, and snippets.

View bhakes's full-sized avatar

BHakes bhakes

View GitHub Profile
import UIKit
import XCTest
/*
Thoughts/Assumptions:
- If we are going to try to find a solution with a time complexity of O(n), we are going to have to get creative.
- We could possibly use two converging indicies, one starting from the from of the string, the other starting from the end.
- Because were taking in a String and returning a String, we could make an extension on String.
- I should consider whether or not 'y' is included as a vowel.

Challenge

Create a function that takes a String and reverses the order of all of the vowels in the String and returns the mutated String without passing through the string more than once. Your solution should have a time complexity of O(n).

Examples:

"Hello" -> "Holle"
"Ben Sean Kat Cam" -> "Ban Saan Ket Cem"
//: A UIKit based Playground for presenting user interface
import UIKit
import PlaygroundSupport
class MyViewController : UIViewController {
var button: UIButton?
override func loadView() {