I have moved this over to the Tech Interview Cheat Sheet Repo and has been expanded and even has code challenges you can run and practice against!
\
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
extension Character: Strideable { | |
public typealias Stride = Int | |
public func distance(to other: Character) -> Character.Stride { | |
guard let first = self.unicodeScalars.first else { | |
fatalError() | |
} | |
guard let other = other.unicodeScalars.first else { | |
fatalError() | |
} |
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
import QuartzCore | |
func executionTimeInterval(block: () -> ()) -> CFTimeInterval { | |
let start = CACurrentMediaTime() | |
block(); | |
let end = CACurrentMediaTime() | |
return end - start | |
} | |