Skip to content

Instantly share code, notes, and snippets.

View sAurangzaib's full-sized avatar

Syed M.Aurangzaib sAurangzaib

  • Nexsys-One Duabi-UAE
  • Dubai-UAE
View GitHub Profile
@thieunguyencrystal
thieunguyencrystal / SmallestPositiveNumber.swift
Created March 21, 2019 11:06
Find the smallest positive number missing from an unsorted array
/*
Given an array of integers, find the first missing positive integer in linear time and constant space. In other words, find the lowest positive integer that does not exist in the array. The array can contain duplicates and negative numbers as well.
For example, the input [3, 4, -1, 1] should give 2. The input [1, 2, 0] should give 3.
You can modify the input array in-place.
*/
func solution(_ array: [Int]) -> Int {
guard let max = array.max(), max > 0 else { return 1 }
@rderik
rderik / .gitignore
Created August 28, 2019 20:44
Xcode gitignore template
# Xcode
## Build generated
build/
DerivedData/
## Various settings
ExportOptions.plist
*.pbxuser
!default.pbxuser