Skip to main content

All Questions

1 vote
1 answer
166 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 ...
Ryan Peschel's user avatar
2 votes
0 answers
266 views

Find Single Element in a Sorted Array, from LeetCode

The problem quoted: https://leetcode.com/problems/single-element-in-a-sorted-array/ Given a sorted array consisting of only integers where every element appears exactly twice except for one element ...
nonopolarity's user avatar
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, ...
Rahul Shivsharan's user avatar
0 votes
1 answer
71 views

My binary search algorithm implementation in JavaScript

I have implemented binary search algorithm in JavaScript: ...
Rahul Shivsharan's user avatar
4 votes
3 answers
160 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 ...
Rahul Shivsharan's user avatar
3 votes
3 answers
227 views

Binary Search Algorithm in JavaScript

I've written this implementation of a binary search algorithm, and wanted to know if it was efficient and where I can improve. ...
Tobi's user avatar
  • 241
2 votes
3 answers
469 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, ...
Software Engineer's user avatar
5 votes
7 answers
12k views

Efficient Binary Search

My implementation: ...
Oliver Morgan's user avatar
40 votes
5 answers
7k views

JavaScript binary search

I wrote an implementation of binary search in JavaScript earlier for kicks, but I noticed my version was significantly different than those found on Google. Here is an example of binary search I found ...
Reid's user avatar
  • 503