JavaScript Interview Questions
Aug. 7th, 2012 02:11 pm![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
Over on his blog Arden Dertat has an excellent series of articles about common interview questions and their solutions. He discusses multiple solutions for almost every problem and talks about their complexities and other advantages and disadvantages. They're a really excellent series of articles and I highly recommend them.
Arden has done many of the solutions in Python or C. I decided it would be helpful to review the questions and present solutions in JavaScript, especially where JavaScript provides its own solutions that Python or C do not. After all, web application development often employs many of the techniques these questions illustrate: string and array manipulation, basic data structures, algorithms and optimization. I won't repeat Arden's excellent discussions of the details (I doubt I could do better), but I will be adding my own observations. I'll also be posting my code on Github as I go.
If anyone has worked through these examples in another language--even if it's just a repo on Github--let me know!
Question 1: Array Pair Sum. Given an array of random integers, output the pairs that add to a given number k.
Question 2: Matrix Region Sum. Given a matrix of integers and coordinates of a rectangular region within the matrix, find the sum of numbers inside the rectangle.
Question 3: Largest Continuous Sum of an Array. Given an array of positive and negative integers, find the largest continuous sum.
Arden has done many of the solutions in Python or C. I decided it would be helpful to review the questions and present solutions in JavaScript, especially where JavaScript provides its own solutions that Python or C do not. After all, web application development often employs many of the techniques these questions illustrate: string and array manipulation, basic data structures, algorithms and optimization. I won't repeat Arden's excellent discussions of the details (I doubt I could do better), but I will be adding my own observations. I'll also be posting my code on Github as I go.
If anyone has worked through these examples in another language--even if it's just a repo on Github--let me know!
Question 1: Array Pair Sum. Given an array of random integers, output the pairs that add to a given number k.
Question 2: Matrix Region Sum. Given a matrix of integers and coordinates of a rectangular region within the matrix, find the sum of numbers inside the rectangle.
Question 3: Largest Continuous Sum of an Array. Given an array of positive and negative integers, find the largest continuous sum.