DEV Community


Interview Question - How to create a text side by side output in node.js (as a diff). From Vanhack

eulier profile image Eulier Gonzalez ・1 min read

This actually was an interview question from VanHack, a platform for remote digital work.

In my blog i explain the details of this

They provide you with 2 assessments and give you 24 hours to solve it.

Even thou i couldn't pass all the test cases of the first assessment, it teach/refresh a lot of concepts from Data Structures, Algorithms, Buffers & Stream over traditionally file read.

Key concepts

Node.js Buffers

A buffer is an area of memory.

A simple visualization of a buffer is when you are watching a YouTube video and the red line goes beyond your visualization point: you are downloading data faster than you're viewing it, and your browser buffers it.

In order words store data to be process later

Node.js Stream

Traditionally, when you tell the program to read a file, the file is read into memory, from start to finish, and then you process it.

Using streams you read it piece by piece, processing its content without keeping it all in memory.

Streams provide two major advantages:

  • Memory efficiency
  • Time efficiency

ReadLine using CreateReadStream in Node

Know your BigO or Asymptomatic Analysis of Data Structures

Github code

Discussion (0)

Editor guide