5 encoding interview questions, asked at Amazon, Apple, Databricks and 3 more companies. Last asked Sep 2026.
Byte-pair encoding tokenizerCodingImplement byte-pair encoding: repeatedly merge the most frequent adjacent pair until the vocabulary reaches its target size, then tokenize with the learned merges. Reported on…
Last asked Sep 2026
Hybrid run-length and bit-packing codecCodingDesign an encoder and a decoder for a list of non-negative integers. The encoder compresses the list into a list of human-readable run strings. The decoder restores the original…
Last asked Aug 2026
Encode and decode TinyURLCodingImplement a class that turns a long URL into a short one and back, in memory. Discuss counter-based versus random or hash-based codes, collisions, the same long URL submitted…
Last asked Jun 2026
+1
Serialize and deserialize a binary treeCodingTurn a binary tree into a string and rebuild the identical tree from that string. Choose a format (pre-order with null markers, or level order), handle empty trees and negative…
Last asked Apr 2026
String compression and decompressionCodingWrite a function that compresses a string (for example with run-length encoding, aaabcc to a3b1c2 or a variant the interviewer gives) and one that decompresses it back exactly…