DEV Community

Eulier Gonzalez
Eulier Gonzalez

Posted on

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

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

Source
Github code

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)

SurveyJS custom survey software

JavaScript Form Builder UI Component

Generate dynamic JSON-driven forms directly in your JavaScript app (Angular, React, Vue.js, jQuery) with a fully customizable drag-and-drop form builder. Easily integrate with any backend system and retain full ownership over your data, with no user or form submission limits.

Learn more

AWS GenAI LIVE!

GenAI LIVE! is a dynamic live-streamed show exploring how AWS and our partners are helping organizations unlock real value with generative AI.

Tune in to the full event

DEV is partnering to bring live events to the community. Join us or dismiss this billboard if you're not interested. ❤️