AMAZON & MICROSOFT Question – Solved

7 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


Related Questions

| The supply chain manager at one of Amazon's warehouses is shipping the last con… |
| Determine the highest value after executing n steps on an infinite 2D grid that… |
| Amazon Prime Video is developing a new feature called "Segmentify." This featur… |
| In this new stock prediction game launched on Amazon Games, Player 1 provides P… |
| Amazon operates numerous warehouses, with each warehouse holding inventory[i] u… |
| In Amazon's highly efficient logistics network, minimizing operational overhead… |