kennymkchan / interview-questions-in-javascript

A mostly reasonable collection of technical software development interview questions solved in Javascript
MIT License
3.61k stars 441 forks source link

Answer to question 1.4 doesn't handle a case of repeating number in array that is not currentMin #32

Closed misstonbon closed 5 years ago

misstonbon commented 6 years ago

array = [7,4,2,9,9,15,1] The answer doesn't handle if array[i] === array[i-1] or in the case of array above, 9,9

kennymkchan commented 6 years ago

Hey @misstonbon! Can you give me an example where the code breaks? The code should work provided your array with: array = [7,4,2,9,9,15,1]. The answer returned should be 13, which is the difference between 2 and 15

misstonbon commented 6 years ago

https://codepen.io/tanjastroble/pen/ZjaaoZ