How do I sort a Binary Search Tree from greatest to least?

I need to return an array of nodes sorted from high to low. At the moment I am trying to implement an inorder traversal which gives me the exact opposite of what I’m looking for. The tree looks like: …

How to remove duplicates by property of an object in an array of objects and copy all properties of duplicates?

I delete all duplicates by the “sourceType” property of the object in the array of objects, but I cannot copy the “dataType” property from the duplicates to the original, please …

JavaScript: return all contiguous subarrays whose sum equals K

This is a variant of this leetcode question, but instead of returning the count, we want to return the actual contiguous sub arrays. For example, if num = [1,2,4,7] k=7 the returned value should be [[…

Find the point where maximum intervals overlap for certain interval length

I’m trying to maximize attendance to a event given a list of busy times for each person. The event can be scheduled anytime between a certain date and hours (Ex. March 1st to March 8th from 9-5) and …

CodeSignal reverseParentheses Failing one case

Write a function that reverses characters in (possibly nested) parentheses in the input string. Input strings will always be well-formed with matching ()s. For inputString = “(bar)”, the …

How to fill 128 boxes with 8 different code from mid of the row using program

I want to fill the 128 boxes with different no. of colors. Let’s consider that I have 8 colors to fillup those boxes and please check the below visual representation for an expected output. I’ve …

Recalculation next position (x and y) based on rotate to N degree

I need to calculate the next position of the shape (X and Y) but don’t have any idea how. I tried different solutions but all-time something went wrong. Maybe someone can help me, I need a tip how it …

JavaScript: Detect a Loop in a Hierarchical Graph

Note that I’ve already gone through How to detect a loop in a hierarchy of javascript elements In our case, we’re not dealing with a linked-list, but a hierarchical graph where each node may have …

how to filter an nested objects inside an array in javascript

I have the following nested objects in an array and i want to filter the result to return the id of a specific item. const data = [ {0: {id: 1, country: “SA”, address: “IOXX”}}, …

Why is this recursion example giving me an infinite loop?

This is driving me insane. Here is the code : function laugh(){ let counter = 10; if(counter <= 0){ return; } else{ console.log('laugh'); counter--; laugh() } } Why ...