You are viewing a single comment's thread. Return to all comments →
swift solution
func compress(input: String) -> String { var input = input var count = 1 var output = "" for char in input { if let last = output.last, last == char { count += 1 }else { if count > 1 { output = output + String(count) count = 1 } output = output + String(char) } } if count > 1 { output = output + String(count) } return output }
Seems like cookies are disabled on this browser, please enable them to open this website
String Compression
You are viewing a single comment's thread. Return to all comments →
swift solution