Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2019
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.26 KB | None | 0 0
  1. public func smallestPositive(array : inout [Int]) -> Int {
  2. var dict = [Int:Bool]()
  3.  
  4. for number in array {
  5. dict[number] = true
  6. }
  7.  
  8. var i = 1
  9. while true {
  10. if dict[i] == nil {
  11. return i
  12. }
  13. i += 1
  14. }
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement