Implement RLE and Bit Packing Encoder
Implement an encoding algorithm that combines Run Length Encoding (RLE) and Bit Packing (BP). RLE encodes consecutive identical elements as RLE[element, frequency] and is applicable when there are 8 or more repetitions. BP packs exactly 8 non-RLE-eligible elements. RLE is always preferred: if the remaining elements at the end of a sequence are all identical (even if fewer than 8), they are encoded using RLE rather than BP. Examples: - [5,5,5] → RLE[5,3] - [1,1,1,2,3,4,5] → BP[1,1,1,2,3,4,5] - [0,0,0,0,0,0,0,0,0,2,3,4] → RLE[0,9], BP[2,3,4] - [1,1,1,1,1,1,1,1,1,2,2,1] → RLE[1,9], BP[2,2,1] - [0,0,0,0,0,0,0,0,0,2,2,2] → RLE[0,9], RLE[2,3]
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
Late August, 2026
Mid August, 2026
Early August, 2026
Hello Interview Premium
Your account is free and you can post anonymously if you choose.