PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Coding & Algorithms/Confluent

Implement tail N lines

Last updated: Mar 29, 2026

Quick Overview

This question evaluates a candidate's skills in file I/O and streaming algorithms, memory-efficient buffering, text encoding correctness (UTF-8), and robustness to system-level file semantics such as seekability, newline conventions, long-line handling, and log rotation.

  • Medium
  • Confluent
  • Coding & Algorithms
  • Software Engineer

Implement tail N lines

Company: Confluent

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Technical Screen

Implement a utility that prints the last N lines of input. Requirements: handle both a regular seekable file and a non-seekable stream (stdin/pipe); support Unix LF, Windows CRLF, and classic Mac CR newlines; operate under tight memory (do not read the entire file); handle extremely long lines that exceed buffer size; preserve UTF-8 correctness when splitting by lines. Follow-ups: extend to `tail -f` (follow file growth), handle log rotation/truncation and symlinks, and support the '-c' option for the last N bytes. Provide data structures, algorithms, time/space complexity, and edge cases.

Quick Answer: This question evaluates a candidate's skills in file I/O and streaming algorithms, memory-efficient buffering, text encoding correctness (UTF-8), and robustness to system-level file semantics such as seekability, newline conventions, long-line handling, and log rotation.

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)
  • Implement File Tail and Sensor Health - Confluent (medium)
  • Rank songs by pairwise user preferences - Confluent (medium)
Confluent logo
Confluent
Jul 27, 2025, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
11
0

Implement a utility that prints the last N lines of input. Requirements: handle both a regular seekable file and a non-seekable stream (stdin/pipe); support Unix LF, Windows CRLF, and classic Mac CR newlines; operate under tight memory (do not read the entire file); handle extremely long lines that exceed buffer size; preserve UTF-8 correctness when splitting by lines. Follow-ups: extend to tail -f (follow file growth), handle log rotation/truncation and symlinks, and support the '-c' option for the last N bytes. Provide data structures, algorithms, time/space complexity, and edge cases.

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.