Created
July 10, 2019 22:07
-
-
Save piyushdec/b142bb77099f62bf8d76f3061726c8f6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| public func smallestPositive(array : inout [Int]) -> Int { | |
| var dict = [Int:Bool]() | |
| for number in array { | |
| dict[number] = true | |
| } | |
| var i = 1 | |
| while true { | |
| if dict[i] == nil { | |
| return i | |
| } | |
| i += 1 | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment