PracHub
QuestionsPremiumLearningGuidesCheatsheetNEW
|Home/Coding & Algorithms/Confluent

Implement File Tail and Sensor Health

Last updated: Apr 16, 2026

Quick Overview

This question evaluates skills in large-file streaming and buffer/pointer manipulation for tailing files, along with data-structure and time-window reasoning for tracking sensor liveness from heartbeat timestamps.

  • medium
  • Confluent
  • Coding & Algorithms
  • Software Engineer

Implement File Tail and Sensor Health

Company: Confluent

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

This interview included two coding tasks. 1. **Print the last `N` lines of a file** You are given a very large newline-delimited text file and a limited file API: - `read(k)`: reads the next `k` bytes from the current file pointer and advances the pointer - `movePointer(pos)`: moves the file pointer to byte offset `pos` - `getSize()`: returns the file size in bytes Write pseudocode to stream the last `N` lines of the file to standard output. The file may be much larger than memory, so you should not read the entire file at once. Also discuss the tradeoffs between scanning with a reusable buffer versus moving the file pointer very frequently. 2. **Track sensor liveness from heartbeat timestamps** A monitoring service receives heartbeats as pairs `(sensorId, timestamp)`, where `timestamp` is a discrete time slot. Implement: - `recordPing(sensorId, timestamp)` - `wasAlive(sensorId, now)` A sensor is considered down if it has missed **three consecutive slots**, so `wasAlive(sensorId, now)` should return `true` if the sensor sent at least one ping during slots `[now-2, now]`, and `false` otherwise. Assume there are many sensors and many queries. Describe or implement an efficient approach, such as using a hash map plus binary search over each sensor's ping history.

Quick Answer: This question evaluates skills in large-file streaming and buffer/pointer manipulation for tailing files, along with data-structure and time-window reasoning for tracking sensor liveness from heartbeat timestamps.

Related Interview Questions

  • Implement Tail and Find Monster Cost - Confluent (medium)
  • Solve Signature, File, and Queue Problems - Confluent (medium)
  • Process pod logs with global increments and pop-min - Confluent (easy)
  • Rank songs by pairwise user preferences - Confluent (medium)
  • Implement tail N lines - Confluent (Medium)
Confluent logo
Confluent
Jan 28, 2026, 12:00 AM
Software Engineer
Onsite
Coding & Algorithms
4
0
Loading...

This interview included two coding tasks.

  1. Print the last N lines of a file You are given a very large newline-delimited text file and a limited file API:
    • read(k) : reads the next k bytes from the current file pointer and advances the pointer
    • movePointer(pos) : moves the file pointer to byte offset pos
    • getSize() : returns the file size in bytes
    Write pseudocode to stream the last N lines of the file to standard output. The file may be much larger than memory, so you should not read the entire file at once. Also discuss the tradeoffs between scanning with a reusable buffer versus moving the file pointer very frequently.
  2. Track sensor liveness from heartbeat timestamps A monitoring service receives heartbeats as pairs (sensorId, timestamp) , where timestamp is a discrete time slot. Implement:
    • recordPing(sensorId, timestamp)
    • wasAlive(sensorId, now)
    A sensor is considered down if it has missed three consecutive slots , so wasAlive(sensorId, now) should return true if the sensor sent at least one ping during slots [now-2, now] , and false otherwise. Assume there are many sensors and many queries. Describe or implement an efficient approach, such as using a hash map plus binary search over each sensor's ping history.

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Confluent•More Software Engineer•Confluent Software Engineer•Confluent Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 7,500+ 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.