DEV Community

Discussion on: Exploring the Two Sum Interview Question in JavaScript

Collapse
 
jhechtf profile image
Jim Burbridge

One other thing that I've seen come up with this problem is an interviewer telling me that I could assume that the given array was already sorted. I said well that's interesting, usually I get told that it's unsorted so you can never be sure. You can make some weird search algorithms using the idea that the array is already sorted. I can't remember exactly what I did but I think it was a rough binary search from there.

The interviewer asked "what would you do if the array wasn't sorted then?" I looked at the board and went "sort it first, before passing it to the function." We both had a good laugh.

Collapse
 
nas5w profile image
Nick Scialli (he/him)

Ha! Well that also says a lot for interviewing skills of asking clarifying questions and explaining your thinking. You definitely have to display technical skills, but at the end of the day you have to convince the interviewer that they'd want to work with you.