Microsoft | Implement tail -f command (Print last n lines of the file)

Difficulty: MEDIUMCategory: InterviewExperienceFrequency: 1Asked On 2024-04-03Added By Anonymous
Source: Link

Hello everyone!


I was recently asked this question during an interview:


Implement a function that prints out last n lines of the file without reading the whole file. (similar to what tail -f does)


Can someone here provide some optimized approach or solution to the problem?


Thanks!

MSFT SDE2 - Phone screen - US

Comments