Skip to main content

All Questions

2 votes
3 answers
198 views

Efficiently tagging first and last of each object matching condition

How can I make the code more readable and more efficient? (provided code is O(n²) time, but intuition says it can be pre-processed and done in O(n) time) Description it tags the first and last of ...
FromTheStackAndBack's user avatar
2 votes
1 answer
62 views

Combining multiple regexps using the `|` operator and grouping the regexps by their flags

I've implemented a function that creates a multiple regular expressions predicate. The idea behind the predicate is combining regular expressions using the disjunction operator ...
terrorrussia-keeps-killing's user avatar
1 vote
1 answer
1k views

Re-order table columns in HTML dynamically with Javascript

I've a table in HTML looks like this: Subjects n1 n2 n3 subject1 10 0 0 subject2 0 5 20 ...
TAHER El Mehdi's user avatar
7 votes
4 answers
6k views

Generate an HTML table using JavaScript from an array of objects

I've an array of objects and I want to convert it into a visual table in HTML; so I did it last night, but I was tired. I don't think it is the right way of doing it, even though it's working and ...
TAHER El Mehdi's user avatar
4 votes
2 answers
195 views

JavaScript Priority Queue implementation using a binary heap

I'm currently going over Robert Sedgewick's Algorithms book. For the implementation of A priority queue using a binary heap I implemented the code using ES6. I believe to have more experience with ...
Steven Aguilar's user avatar
3 votes
2 answers
153 views

Quicksort implementation in JavaScript

I implemented Quicksort in JavaScript. I'm trying to follow the best principles in JavaScript. In Ruby when you declare classes your able to use private for the ...
Steven Aguilar's user avatar
1 vote
1 answer
68 views

Bidirectional numeric (floating point) sequence iterator

I wanted a neat iterator that will always give me neat sequence of step spaced numbers. This is what I came up with, but I am a bit skeptical that I covered all ...
Tomáš Zato's user avatar
8 votes
5 answers
1k views

Expanding powers of expressions of the form ax+b

I solved the following problem: Write a function expand that takes in an expression with a single, one character variable, and expands it. The expression is in the form ...
haxor's user avatar
  • 111
3 votes
1 answer
1k views

Shortest way to form a string out of a subsequence of a string

The task is taken from LeetCode (subscription required) - From any string, we can form a subsequence of that string by deleting some number of characters (possibly no deletions). Given two strings ...
thadeuszlay's user avatar
  • 3,981
6 votes
4 answers
3k views

Find all letter Combinations of a Phone Number

The task is taken from LeetCode Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent. A mapping of digit to letters (just ...
thadeuszlay's user avatar
  • 3,981
2 votes
1 answer
757 views

Given time intervals determine if a person could attend all meetings

The task is taken from LeetCode Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],...] ...
thadeuszlay's user avatar
  • 3,981
5 votes
1 answer
8k views

Merge Two Sorted Lists in JavaScript

The task is taken from LeetCode Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists. Example 1: ...
thadeuszlay's user avatar
  • 3,981
8 votes
1 answer
2k views

Merge Intervals in JavaScript

This is a task taken from Leetcode - Given a collection of intervals, merge all overlapping intervals. Example 1: ...
thadeuszlay's user avatar
  • 3,981
1 vote
3 answers
545 views

Jewels and Stones

The task is taken from leetcode You're given strings J representing the types of stones that are jewels, and S representing the stones you have. Each character in S is a type of stone you have....
thadeuszlay's user avatar
  • 3,981
5 votes
1 answer
323 views

Find the starting indices of all occurrences of the pattern in the string - KMP algorithm follow-up

The task was initially solved here, but was too buggy: Given a string and a pattern, find the starting indices of all occurrences of the pattern in the string. For example, given the string "...
thadeuszlay's user avatar
  • 3,981

15 30 50 per page
1
2 3 4 5