Skip to content

Instantly share code, notes, and snippets.

@piyushdec
Created July 10, 2019 22:07
Show Gist options
  • Select an option

  • Save piyushdec/b142bb77099f62bf8d76f3061726c8f6 to your computer and use it in GitHub Desktop.

Select an option

Save piyushdec/b142bb77099f62bf8d76f3061726c8f6 to your computer and use it in GitHub Desktop.
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