FastPrepOut-of-Order TLV File Reassembly
Problems/Out-of-Order TLV File Reassembly

Out-of-Order TLV File Reassembly

Applied Intuition logoApplied Intuition● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an Applied Intuition full-time phone screen. The report keeps the goal of putting 32-bit packets back together when they arrive out of order. It leaves out the exact bit layout, how a batch starts and ends, the rules for fragments, how the output is written, and the input limits. We chose those. Our version is about 80% the same as the reported question.

You are given a batch of TLV (type, length, value) packets in packets. The batch holds every packet of every message. Each packet is an unsigned 32-bit value stored in a long. Its bits are laid out like this:

  • Bits 31..28: message ID.
  • Bits 27..24: packet index.
  • Bits 23..20: packet count minus one.
  • Bits 19..18: field type, where 0 is a filename fragment, 1 is permission, and 2 is file data.
  • Bits 17..16: payload length.
  • Bits 15..0: payload.

Packets can arrive in any order. Inside each message, handle the packets in increasing packet index.

  • A filename or data packet has payload length 0, 1, or 2. For length 1, the low byte is the fragment. For length 2, read the high byte and then the low byte. Length 0 contributes an empty fragment.
  • A permission packet has payload length 1; its permission value is the low nine payload bits.
  • Concatenate filename fragments and data fragments independently in packet-index order.

Return one string per message in ascending message-ID order. Format each result as filename|permission|content, where permission is written in decimal.

Function

reassembleTlvFiles(packets: long[]) → String[]

Examples

Example 1

packets = [591023947,556859491,540172590,573899172]return = ["a.c|420|OK"]

All four packets have message ID 2 but arrive in index order 3, 1, 0, 2. Reordering them yields filename fragments "a." and "c", permission 420, and data "OK".

Example 2

packets = [304676929,54001664,270598264,19988579,287637997,3301934,37028224]return = ["b.c|384|","x|493|A"]

The packets of messages 0 and 1 are mixed together. Results are sorted by message ID. Message 0 comes first. Its data fragment is empty, so its content is empty. Message 1 rebuilds the content "A".

Constraints

  • 1 <= packets.length <= 256.
  • Each value is in the unsigned 32-bit range [0, 2^32 - 1].
  • Message IDs and packet indexes are in [0, 15].
  • Every message has one consistent packet count in [1, 16], and exactly the packet indexes from 0 through count - 1 appear once.
  • Field type 3 does not appear.
  • Each message has at least one filename packet and exactly one permission packet.
  • Filename and data payload bytes are printable ASCII other than |. Unused payload bits are zero.
  • Permission is in [0, 511].

More Applied Intuition interview questions

  • KV Store with Nested TransactionsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Parse Nested Message TypesPHONE SCREEN · Seen Nov 2026
  • Resolve Variable Equations with Dependency ErrorsPHONE SCREEN · Seen Nov 2026
  • Locate Vehicles with Square QueriesPHONE SCREEN · Seen Nov 2026
  • File-Backed Dense Game of LifePHONE SCREEN · Seen Oct 2026
  • Merge Collinear Point SegmentsPHONE SCREEN · Seen Oct 2026
  • Compilation Order with Topological SortPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Merge Overlapping Closed IntervalsPHONE SCREEN · Seen Sep 2026
  • Ring Buffer OperationsPHONE SCREEN · Seen Aug 2026
  • Hash Map with Separate ChainingONSITE INTERVIEW · Seen Nov 2026

Similar questions at other companies

  • Query Log MatchDatadog · PHONE SCREEN · ONSITE INTERVIEWDatadog interview questions
  • Evaluate Ordered Action RulesStripe · PHONE SCREEN · ONSITE INTERVIEWStripe interview questions
  • Machine Message RouterOpenAI · PHONE SCREENOpenAI interview questions
  • Ordered IP FirewallDatabricks · PHONE SCREENDatabricks interview questions
  • Reversible Run-Length EncodingZillow · PHONE SCREENZillow interview questions
  • Format CSV Rows as an ASCII TableAmazon · PHONE SCREEN
  • Repeated Mirror XORMathWorks · OAMathWorks interview questions
  • Game of Life: In-Place Next GenerationGoogle · ONSITE INTERVIEWGoogle interview questions
  • 2048 Simulation and Board CodecCitadel · ONSITE INTERVIEWCitadel interview questions
  • Bank Requests with Delayed CashbackRamp · OARamp interview questions
All Applied Intuition interview questionsSee Applied Intuition hiring insights
Saved
class Solution {
    public String[] reassembleTlvFiles(long[] packets) {
        // write your code here
    }
}
Checking account…