All Questions
6 questions
1
vote
2
answers
852
views
Merge two sorted arrays that can be of different sizes
I think the algorithm implementation itself is reasonably efficient, but I'm not sure about proper use of good practices in software development in the code (variable naming, idioms, comments, error ...
6
votes
1
answer
1k
views
Multiple stacks implemented via a linked lists on top of single fixed-size array
Problem Statement
Originally, the problem is defined in the book as following:
Describe how you could use a single array to implement three stacks. — Cracking the Coding Interview (6th edition)
...
5
votes
3
answers
126
views
Array's reverse vs simple arithmethic
I was asked to print numbers from 100 to 1 in a for loop with the index starting from 1. I came up with this solution:
...
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, ...
4
votes
3
answers
2k
views
Removing duplicates from an array
I recently wrote this JavaScript algorithm for removing duplicates from an array as part of a job interview process, but was turned down for the position after submitting the code. I didn't receive ...
12
votes
7
answers
31k
views
Given an array of integers, return all pairs that add up to 100
I was recently given this programming challenge on an interview, and I decided to use javascript to solve it. I did, but I'm not happy with my implementation. I can't help thinking there must be a ...