You are viewing a single comment's thread. Return to all comments →
this got me too. Very frustrating. Here is Scanner code that works.
Thanks @doktoren for the lead.
(Credit to Martin R on StackExchange for this code https://codereview.stackexchange.com/users/35991/martin-r)
public func splitToIntegers(_ s: String, count: Int) -> [Int] { var result: [Int] = [] result.reserveCapacity(count) var n = 0 let scanner = Scanner(string: s) while scanner.scanInt(&n) { result.append(n) } return result } let d = Int(readLine()!)! for _ in 0..<d { let length = Int(readLine()!)! let ary = splitToIntegers(readLine()!, count: length) //... }
Seems like cookies are disabled on this browser, please enable them to open this website
Merge Sort: Counting Inversions
You are viewing a single comment's thread. Return to all comments →
this got me too. Very frustrating. Here is Scanner code that works.
Thanks @doktoren for the lead.
(Credit to Martin R on StackExchange for this code https://codereview.stackexchange.com/users/35991/martin-r)