PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Hudson

Implement Buffer Parsers and Generic Map Class

Last updated: Apr 6, 2026

Quick Overview

This question evaluates proficiency in low-level C++ buffer parsing, memory and pointer management, safe binary deserialization, and template-based generic container design with type-restricted map wrappers.

  • medium
  • Hudson
  • Coding & Algorithms
  • Data Scientist

Implement Buffer Parsers and Generic Map Class

Company: Hudson

Role: Data Scientist

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Take-home Project

In C++, complete the following two independent implementation tasks. 1. **Sequential buffer reader** You are given a raw byte buffer and a current pointer or offset. Implement three functions that read the next value as `char`, `int`, and `std::string` respectively. After each successful read, the pointer must advance so that the next call continues from the correct location. Assume the binary encoding is: - `char`: 1 byte - `int`: 4 bytes - `std::string`: a 4-byte length followed by that many bytes Your functions should: - verify that enough bytes remain before reading, - safely convert the raw bytes into the requested type, - advance the pointer or offset only on success, - avoid unnecessary copying or allocations. 2. **Generic map wrapper** Implement a template class that can operate on either `std::map<K, V>` or `std::unordered_map<K, V>`, where both `K` and `V` are restricted to `int` or `std::string`. The class should: - accept one of these containers in its constructor, - support inserting key-value pairs, - support querying a key and returning either the associated value or a clear `not found` result, - output all stored entries in `key:value` format, one entry per line, - handle empty containers correctly. For `std::unordered_map`, any output order is acceptable. You may use template overloading or specialization if needed.

Quick Answer: This question evaluates proficiency in low-level C++ buffer parsing, memory and pointer management, safe binary deserialization, and template-based generic container design with type-restricted map wrappers.

Related Interview Questions

  • Solve Watcher Simulation And Integer Conversion - Hudson (medium)
  • Count People Reaching the Boundary - Hudson (easy)
  • Implement Order Modification Feature - Hudson (hard)
  • Count inversions in a permutation - Hudson (medium)
  • Count players reaching end with moving watchers - Hudson (easy)
Hudson logo
Hudson
Apr 2, 2026, 12:00 AM
Data Scientist
Take-home Project
Coding & Algorithms
1
0
Loading...

In C++, complete the following two independent implementation tasks.

  1. Sequential buffer reader You are given a raw byte buffer and a current pointer or offset. Implement three functions that read the next value as char , int , and std::string respectively. After each successful read, the pointer must advance so that the next call continues from the correct location. Assume the binary encoding is:
    • char : 1 byte
    • int : 4 bytes
    • std::string : a 4-byte length followed by that many bytes
    Your functions should:
    • verify that enough bytes remain before reading,
    • safely convert the raw bytes into the requested type,
    • advance the pointer or offset only on success,
    • avoid unnecessary copying or allocations.
  2. Generic map wrapper Implement a template class that can operate on either std::map<K, V> or std::unordered_map<K, V> , where both K and V are restricted to int or std::string . The class should:
    • accept one of these containers in its constructor,
    • support inserting key-value pairs,
    • support querying a key and returning either the associated value or a clear not found result,
    • output all stored entries in key:value format, one entry per line,
    • handle empty containers correctly.
    For std::unordered_map , any output order is acceptable. You may use template overloading or specialization if needed.

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Hudson•More Data Scientist•Hudson Data Scientist•Hudson Coding & Algorithms•Data Scientist Coding & Algorithms
PracHub

Master your tech interviews with 8,000+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.