Amazon | Phone screen | Compression of String
Anonymous User
1345

Position: SDE1

An input string that only contains all lower case letters is given as shown below.
Each character in the input string is stored in a byte.
Task is to encode the string in a way it uses minimum space. (all lower case letters, so each letter could be stored in 5 bits instead of 8 bits).

Once the string is encoded, we need to write a decode function to generate original string so need to also store end of a word indicator.

char* inputArray[] = {"this", "is", "an", "input", "string"};

int encode(char** inputArray, int n, char* strEncoded)
{
}

int decode(char** outputArray, int n, char* inputStr)
{
}
Comments (4)