Company: IDFC First Bank
Difficulty: easy
Repeat Every Bit Three Times A simple line encoder spells out a message in binary and then stretches every bit so that a noisy channel still carries it through: each bit is transmitted three times in a row. You are given a string s of lowercase English letters. Build the encoded string as follows. For each character of s , in order from left to right: Take the character's ASCII value. For lowercase English letters this is 97 for 'a' through 122 for 'z' . 2. Write that value in binary, most significant bit first and with no leading zeros . Because every lowercase letter has an ASCII value between 97 and 122 , this is always exactly 7 bits. 3. Replace every bit of that binary representation by three copies of itself: each 0 becomes 000 and each 1 becomes 111 . The encoded string is the result for the first character, followed by the result for the second character, and so on, joined directly with no separator between characters . Return the encoded string. It always has length exactly 21