Manipulating AlgoExpert linked lists in VS Code

Danira Cortez
3 min readFeb 22, 2021

--

This tutorial will go over how to display linked lists from AlgoExpert in VS Code

AlgoExpert logo

During my job search, I’ve been studying data structures and algorithms, as they are not covered in bootcamps. There are many resources to learn DS&A, from courses to books, to videos. I decided to purchased AlgoExpert because of my learning style and their video explanations. Although their platform has everything you need to solve the problems, I like practicing on VS Code, as that’s the IDE I use. I was able to practice this way until I got to linked lists.The Problem

Up to this point, I was able to copy and paste the inputs to test my functions. Most of the data inputs had been strings, integers, and arrays, but linked lists aren’t as simple. In my next article, I will go into detail about linked lists and creating them in JavaScript. However, this one will focus on data input. *I also won’t be sharing the problem due to copyright issues.

I was given a problem in which I had to manipulate the linked list above, provided as the input. Like other problems, I copied the layout into VS Code. However, the way the linked list data was structure as so:

Input data from AlgoExpert

Each node in the linked list has an id, points to the next node’s id, and a value. Unfortunately, when running the file, VS Code can not read the values of the nodes. I manipulated the input data in a variety of ways to get it to work with no luck. Finally, I found that for JavaScript, a linked list is written as follows:

Input data in JavaScript format
  • Each node has a value and points to the next node in a nested object versus an array of objects as above.

Problem Solved…Maybe

Once I had the correct format I figured everything would work properly. That was not the case. Apparently, VS Code has a limit on how much information it shows in the terminal. If you were to console.log the input you’d get the following:

console.log the input
What the terminal displays

This clearly makes solving algorithms difficult. To show the show all the properties of a JavaScript object you can use console.dir, with a depth of null.

console.dir the input
What the terminal displays

Conclusion

Although I probably should have already known JavaScript’s format for linked lists, I would have never learned it if I wasn’t practicing AlgoExpert problems in VS Code. With the correct format and using console.dir, one can manipulate and view linked lists in VS Code. My next article will cover creating linked lists but for now, you can practice manipulating linked lists.

--

--

Danira Cortez

Software Engineer | React, JavaScript, Ruby on Rails | Seeking job opportunities