🎁 Exclusive Offer! Join our Telegram Channel to get **special discounts** and updates! 🚀

🚀 Struggling with coding interviews? We've got you covered! 💡 Practice real questions, sharpen your skills, and land your dream job! 🎯
Question 78 - 100% Working Solution | Buy Now

Description

2 Live
String Encoding Encode a given string by collapsing consecutive instances of a single character into two pieces of information: the number of instances and the character. Note that even single characters should be run-length encoded. If the string is empty, return an empty string. Your implementation should work on all alphanumeric characters. Function Description Complete the function collapselnput which takes a string input as a parameter and returns the compressed string. Sample Input: GGGGGrrrrrrrrrrrrttt Sample Output: 5G14r3t Explanation: There are 5 'G' characters, then there are 14 'r's, then there is 1 't'.

Asked in: AMAZON MICROSOFT

Image of the Question

Question Image

All Testcases Passed ✔



Passcode Image

Solution


Please login to view the solution