Array.from and Tree structure in JavaScript. Codingame: Telephone Numbers – Solved


Programming shouldn’t be boring. Let’s play with a Codingame’s puzzle today. [Music playing] Hi! Let’s play and solve a puzzle titled “Telephone
Numbers” by Codingame. I’m Anatol and you are watching the Good Parts
of the FrontEnd development. If this is your first time here, you wanna
learn Frontend and JavaScript, start now by subscribing and don’t forget to turn on
the subtitles. [Music playing] The story tells: Dang, all those telephone
numbers are impossible to remember! What if we were to invent a new way to store
phone numbers so that they take the least memory space? It is your task today to achieve that hard
work. Then call me, maybe? In this puzzle, you learn new ways and reasons
to store data in optimized structures such as Tree. The goal of this puzzle is to store multiple
phone numbers in a compact way, using a tree data structure, then count all the nodes there
are in this tree. I’ve told about Tree Data Structures earlier
in this video, so you can check the link in the description. To create a list of the numbers I use Array.from
method. It creates a new Array instance from an array-like
or iterable object. It has following syntax. Let’s dive into the code. [Music playing] Read a list of number and set the initial
values Build a tree using given list Now calculate the nodes Let’s test it Tests are green. Good job! That’s pretty easy, isn’t it? Next time let’s have a look at “There is no
spoon” puzzle. [Music playing] My code is available on GitHub
Documentation is available in the Internet Follow the links if you’re eager to get
more. [Music playing] If you like this video give it “thumbs up”,
share it with your friends, subscribe to the channel and watch other episodes. Thanks for watching and dive deeper.

Leave a Reply

Your email address will not be published. Required fields are marked *