Available question text
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]
Related questions
Continue with questions that share topics or the same question type.
Sources · 1 reference
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 1 record
Databricks
Implement RLE and Bit Packing Encoder
Reported Sep 30, 2026 · 7 source reports
SENIOR, STAFF
Source snapshot: Nov 12, 2026
View source