Snowflake | Online Assessment | Word Compression

Question :

Need to compress the given string where we need to remove the k consecutive same characters and output the compressed string.

Ex: input String : aabbad k=2
output compressed string : ad
Explanation: firstly remove bb...we get aaad now we have two a's consecutive..so remove them. So, final compressed string is "ad" .

Comments (3)