Untitled
unknown
plain_text
22 days ago
783 B
5
Indexable
Never
/** String Compression Algorithm The task: Input: "aabcccccaaa" Output: "a2b1c5a3" */ func stringCompression(input: String) -> String { var localStr = "" var count = 1 var tempArray = [String]() for char in input { let tempLast = tempArray.last if tempLast == "\(char)" { count += 1 if count > 1 { } else { } tempArray.append("\(count)") continue } tempArray.append("\(char)") } return "" }
Leave a Comment