Untitled
unknown
plain_text
a year ago
783 B
11
Indexable
/**
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 ""
}Editor is loading...
Leave a Comment