You know what they say; if you can’t beat them, join them. The set up I have set up a repository with four distinct directories. . ├── data-structures ├── leetcode ├── problem-solving-patterns └── searching-algorithms Each directory corresponds to the relevant section I am studying for. Let’s take for example a singly linked list. I would create the main and test files under data-structures. data-structures ├── singly-linked-list.js └── singly-linked-list.test.js In the main file goes the code. Bellow, is the implementation for the linked list example we are talking about. The two necessary classes are defined alongside the named export needed for the tests. For the sake of brevity I have only included the push method of SinglyLinkedList. class Node { constructor(val) { this.val = val; this.next = null; } } class SinglyLinkedList { constructor() { this.head = null; this.tail = null; this.length = 0; } push(val) { const newNode = new Node(val); if (!this.head) { this.head = newNode;…
No comments yet. Log in to reply on the Fediverse. Comments will appear here.