Untitled

mail@pastecode.io avatar
unknown
plain_text
5 months ago
783 B
5
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 ""
    }
Leave a Comment