Skip to main content

All Questions

Filter by
Sorted by
Tagged with
7 votes
1 answer
239 views

Find the longest "common sequence" in two lists

In short, the algorithm must find the longest sequence that joins together common sequences from two lists (a more formal specification is given in the code's header). The lists are assumed to contain ...
user266319's user avatar
7 votes
1 answer
769 views

Get all partitions of an array into k non-empty sub-arrays

I am writing a function that takes an array and an integer number and returns an array of all the partitions into subarrays (so an array of arrays of subarrays). The number of subarrays is exact the ...
Joji's user avatar
  • 335
0 votes
1 answer
148 views

Can I optimize my implementation of generating Fibonacci series using recursion?

My function accepts a number, which generates total Fibonacci numbers. I am using recursion. Please follow the code below, ...
Rahul Shivsharan's user avatar
6 votes
2 answers
449 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 ...
Christopher Chen's user avatar
3 votes
1 answer
569 views

Find A Series of Numbers Who when Squared and Summed are equal to a given Square

I am working on a CodeWars titled 'Square into Squares. Protect trees!' it can be found here: https://www.codewars.com/kata/54eb33e5bc1a25440d000891/train/javascript I have a working solution, the ...
Cory Harper's user avatar
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 ...
Eric's user avatar
  • 181
1 vote
2 answers
248 views

When given 7 letters, find all possible words with length 3 to 7

I am writing a program in JavaScript to find all possible words given 7 letters. The words have to be 3 or more characters, and for right now I am limiting it to 7 characters long. The code below ...
Wowsk's user avatar
  • 113
4 votes
0 answers
143 views

All the paths from the root to the leaves

Given a binary tree, return all root-to-leaf paths. Example: -- 1 / \ 2 3 \ 5 Output should be: ["1->2->5", "1->3"] My approach: I walk the branches ...
Rick's user avatar
  • 586
1 vote
1 answer
1k views

Count number of islands 2d grid

This is a recursive approach using DFS to counting the number of islands. However, I would like to improve performance, while keeping the code clean concise and readable. Better yet can this be solved ...
Rick's user avatar
  • 586
5 votes
1 answer
1k views

Recursively generating the look-and-say sequence

I have a pattern where every number is counted by the number of repetitions. A new resulting number is formed by adding that repetition to the front of that value. The resulting pattern would look ...
Rick's user avatar
  • 586
1 vote
2 answers
3k views

Filtering on an array of object literal properties and their nested array values

This is a function which filters on multiple object properties and their corresponding arrays. I need to match all properties to a pattern and have an array as their property value. Properties that ...
Rick's user avatar
  • 586
3 votes
1 answer
2k views

Return path to a value in a nested object

Description: Its not a programming challenge but I though to write a small utility which will return the path to a primitive value in a possibly nested object. The idea is not original. Code: ...
CodeYogi's user avatar
  • 5,177
5 votes
0 answers
187 views

Assembling and traversing a graph, given a list of items and parent pointers

I've written a function which takes input such as this: ...
Tomáš Hübelbauer's user avatar
3 votes
1 answer
336 views

Hand crafted longest common sub sequence

I know that the below solution is not the best one and I am in the way to learn that stuff till then I have applied the brute force to see how far I can go with my intuition. ...
CodeYogi's user avatar
  • 5,177
4 votes
1 answer
4k views

Get all combination of a nested object

I have JSON data which can be an object/array of recursively nested object or array. The value of an array can not be null, but a value in an object can be null. And I would like to return all ...
Mike Lee's user avatar
  • 165

15 30 50 per page