All Questions
19 questions
12
votes
1
answer
743
views
Make a summary from a larger text-file
This code makes summaries from larger texts.
I have searched around for an algorithm and found the following:
Associate words with their grammatical counterparts. (e.g. "city"
and "cities")
...
8
votes
1
answer
351
views
Sieve of Eratosthenes performance; Scala very slow compared to Node.js
I am new to Scala so it might show. I am learning it for one of my classes and have to write a performance benchmark. I have written the Sieve of Eratosthenes in both Node.js and Scala, and my Node.js ...
6
votes
2
answers
446
views
Selection Sort Algorithm (Node.js)
I wanted to implement a selection sort and wanted to make sure that I'm doing it correctly. I wanted to do it in a way that's efficient and use recursion. Please let me know if I am doing this ...
5
votes
2
answers
2k
views
Hackerrank.com - Sherlock and Anagrams
Summary: Given a string find the number of anagramic pairs of substrings of it. e.g 'abba' pairs are [a,a],[b,b],[ab,ba],[abb,bba] so we have 4 pairs.
I'm wondering if anyone can help me improve my ...
4
votes
1
answer
101
views
Reducing code duplication in a geometric function
Given a large bounding rectangle ("envelope"), a list of points, and a maximal aspect ratio, the goal is to find a rectangle within the envelope, whose aspect ratio is bounded within the given aspect ...
4
votes
1
answer
95
views
Function to check that two objects have "equivalent" values
I have two objects, a bet and a match. A match has 2 teams and both teams get a score at the end of the match. A bet has two scores set up before the match begins. Here I need to know if the bet ...
4
votes
0
answers
345
views
JavaScript AVL Tree
I have been working through Introduction to Algorithms 3rd Edition, and have implemented an AVL tree through prototypal inheritance. The code presented here does work as expected based on the tests ...
3
votes
1
answer
212
views
Update user's experience points
I have a private method in my class to update user experience.
First of all, I create giveExp based on contentLength (...
3
votes
2
answers
76
views
Javascript best way to filter out empty values and simplify reusable function
Hello I have this function that takes array of objects and takes a specific value from the object and creates array of strings that can make mapped to dropdown selector.
...
3
votes
0
answers
4k
views
Depth first search implementation
I've been practicing my algorithms using The Algorithm Design Manual. I've decided to implement the depth first search section (5.8) using javascript. Note you can execute the code here if you don't ...
2
votes
2
answers
1k
views
Generate all possible unique combinations of positive numbers these have sum equal to N
This is my function to generate all possible unique combinations of positive numbers these have sum equal to N.
For example:
If the input is 4
The output should ...
2
votes
2
answers
119
views
Javascript/Node: Reducing a sorted array of pairs such that the values corresponding to the same key are summed
System/Language: I'm using plain Javascript to write this algorithm. Environment: Node 17.4.0 with a system that has ~7000 MiB of Memory and ~400GB of Storage.
Input Data
An (...
2
votes
2
answers
3k
views
Add new number to sorted array of numbers
The task is to add a new number in the array of numbers sorted in ascending order.
So let's say the array is:
20,40,50,60
And the number to be inserted is 24,
...
2
votes
2
answers
118
views
Find differences between two arrays
I have to identify added and deleted items between two objects with the same structure.
...
2
votes
0
answers
51
views
Flatten Hierarchical Categories
I have an XLSX file that contains a hierarchical list of categories. Each category has a basic query associated with it. I need to flatten these categories which involves combining the categories. I ...