Skip to content

Tag: algorithm

Build nodes like array from flat array

I’m trying to restructure the following javascript flat array without parent_id. I want to have a structure for React Tree Table like example in this page: I want a another array that dynamically group according to this array’s keys: I want to have a structure like this and pass an another array to group. Ideally a want sum the

Better way to reverse a linkedlist in javascript

I tried this: And my Node class: here head is the main LinkedList’s head, and HEAD is the head of new one. I’m using stack here. And the algorithm is in linear complexity. Instead of creating new Node everytime, I think there is some better way to implement this. Can you suggest some other ways? Also is it possible to