Skip to main content

All Questions

Filter by
Sorted by
Tagged with
1 vote
1 answer
170 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
4 votes
1 answer
146 views

JavaScript Binary Search -- first try

EDIT: code snippet added, check the output in JS console I wrote the following binary search algorithm in JS, for the first time in my experience. The variable ...
one-hand-octopus's user avatar
2 votes
1 answer
167 views

Leetcode Search in Rotated Sorted Array

I was doing Search in sorted array question from leetcode Question Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. (i.e., [0,1,2,4,5,6,7] might become [4,...
iRohitBhatia's user avatar
2 votes
0 answers
272 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
1 answer
197 views

Challenge - Construct binary tree from array [closed]

A coding challenge to construct a binary tree from an array. ...
Drewsup123's user avatar
2 votes
0 answers
55 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 ...
Rick's user avatar
  • 586
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
3 votes
2 answers
913 views

Binary search on real space

I want to perform a binary search on a continuous unimodal function ƒ(x)=y, where x and y are real numbers. I'm not looking up values in an array, and so I don't have clean integer inputs that I'm ...
Phrogz's user avatar
  • 719
0 votes
1 answer
79 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
171 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
1 answer
3k views

HackerRank: Climbing the Leaderboard

Below is my solution to Climbing the Leaderboard on HackerRank: Alice is playing an arcade game and wants to climb to the top of the leaderboard. Can you help her track her ranking as she beats ...
dagda1's user avatar
  • 309
5 votes
2 answers
2k views

Calculate the sum at a level of a binary tree represented in a String

Fair preface: This is an interview question I would like to improve my knowledge of. I got some rest, and re-solved the problem with a fresh/unpanicked mind. Given input of the type ...
Hodrobond's user avatar
  • 173
3 votes
1 answer
783 views

Implement the merge sort + binary search algorithms to filter and merge sort two arrays

I wanted to take my own shot at a merge sort array implementation. I took on the prompt from Rahul's post. The goal (altered a little for my purposes): Implement a solution capable of merging & ...
George Harrison Burrows IV's user avatar
3 votes
3 answers
238 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
1 vote
1 answer
4k views

Binary search on string in alphabetical order

The code for a binary search on an ordered string by alphabetical orders seems to work. I am wondering if there is a better way to write this. ...
Aaron's user avatar
  • 965

15 30 50 per page