Find the floor number with given room number?
Code
func findFloor(roomPattern: [Int], roomNo: Int) -> Int {
var floor = 0
var count = 0
while count < roomNo {
floor += 1
let index = (floor - 1) % 2
count += roomPattern[index]
}
return floor
}