All Questions
7 questions
1
vote
1
answer
168
views
Finding the closest values in a sorted list that don't go under/over
For my project I have a sorted array of objects of timestamps (in milliseconds) and I need two functions. One function should find the closest time that doesn't go over a specific amount, and the ...
-2
votes
1
answer
189
views
Challenge - Construct binary tree from array [closed]
A coding challenge to construct a binary tree from an array.
...
2
votes
0
answers
51
views
Find target in sorted array pivoted at some unknown point in O(log n)
You are given an array sorted in ascending order which is rotated at
some pivot unknown to you beforehand. Find your target in \$O(log n)\$
which means it should be a binary search. If the value ...
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,
...
4
votes
3
answers
166
views
My Binary Search Implementation
I have implemented binary search in JavaScript.
I run it on node.
I pass an comma separated string of numbers in ascending order as first argument and the number to be searched in the second ...
2
votes
3
answers
470
views
Minimum element in a sorted rotated array
A sorted array [0,1,2,3,4,5] when rotated n times (3 times in this case) becomes [3,4,5,0,1,2], meaning elements in the front move to the end. The code below finds the minimum element in this array, ...
5
votes
2
answers
584
views
Binary search that returns bitwise complement of missing index
While re-writing some old JavaScript code to better handle large arrays, I ended up writing my own binary search method.
I found many examples of binary search methods written in JavaScript, but all ...