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
@objc protocol Timer { | |
func scheduleTimer(target:AnyObject, selector: Selector, interval: NSTimeInterval)->String | |
func cancelTimer(id:String) | |
} | |
@objc class NSTimerService: Timer { | |
var timers:[String:NSTimer] = [:] | |
func scheduleTimer(target:AnyObject, selector: Selector, interval: NSTimeInterval)->String { | |
let id = NSUUID().UUIDString |
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
Note: clientId and facId are primary keys to the server database, numbers stored in NSStrings | |
// Mandatory fields: clientId, facId | |
- (NSError *)validateData { | |
id sel1 = [NSValue valueWithPointer:@selector(clientId)]; | |
id sel2 = [NSValue valueWithPointer:@selector(facId)]; | |
return [self validateMandatoryFields:@[sel1, sel2]]; | |
} |
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
let test1 = [[0,1,1,0,1], | |
[0,1,0,1,0], | |
[0,0,0,0,1], | |
[0,1,0,0,0]] | |
let test2=[[0]] | |
print( minHours(test1)) | |
print(minHours(test2)) | |
} | |
func minHours(_ matrix:[[Int]]) -> Int { |
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
let islands = [[1,0,0,0,0],[0,0,1,1,0],[0,1,1,0,0],[0,0,0,0,0],[1,1,0,0,1],[1,1,0,0,1]] | |
print(numberOfIslands(islands)) | |
func numberOfIslands(_ islands:[[Int]]) -> Int { | |
if islands.count == 0 { | |
return -1 | |
} | |
var grid = islands | |
var numberOfIslands = 0 |