FastPrepParse a Binary Firmware Header
Problems/Parse a Binary Firmware Header

Parse a Binary Firmware Header

AMD logoAMD● MediumNEW GRADONSITE INTERVIEW
QuestionFunctionExamplesConstraints

Problem statement

Source note: The source asks to parse binary GPU firmware headers with endianness handling but supplies no layout. The complete GPUF header, fields, valid-only domain and portable interface are authored practice assumptions; approximate source match60%.

Parse the following authored practice header and return [version,imageSize] as nonnegative64-bit values. This is a practice format, not a documented AMD firmware layout.

  • Bytes0..3: ASCII GPUF magic.
  • Byte4: byte-order tag,0=little-endian and1=big-endian.
  • Bytes5..6: unsigned16-bit version.
  • Bytes7..10: unsigned32-bit imageSize.

The tag applies to both numeric fields. The input contains only the11-byte header; imageSize is metadata and does not imply a payload is included. Inputs are valid headers; validation of malformed files is outside this contract.

Function

parseFirmwareHeader(data: int[]) → long[]

Examples

Example 1

data = [71,80,85,70,0,2,1,4,3,2,1]return = [258,16909060]

Little-endian bytes [2,1] give version258; [4,3,2,1] give imageSize16909060.

Example 2

data = [71,80,85,70,1,255,255,255,255,255,255]return = [65535,4294967295]

All-one numeric fields are the maximum unsigned16 and unsigned32 values, returned positively.

Constraints

  • data.length == 11.
  • 0 <= data[i] <= 255.
  • The first four bytes are [71,80,85,70] (ASCII GPUF), and data[4] is either 0 or 1.

More AMD problems

  • Insert After a Linked-List NodeONSITE INTERVIEW · Seen Oct 2026
  • LRU CacheONSITE INTERVIEW · Seen Oct 2026
  • Lowest Common Ancestor of a Binary TreePHONE SCREEN · Seen Oct 2026
All AMD interview questionsSee AMD hiring insights
Saved
public long[] parseFirmwareHeader(int[] data) {
    // Write your code here.
}
Checking account…