you could solve this with a simple state machine; there's no reason to resort to parlour tricks... https://gist.github.com/igor47/7228586
https://gist.github.com/alexchow/7228746
Try the case: ([2,5,1,2,3,4,7,7,6,3,5], 12)
21–30 of 86 posts
you could solve this with a simple state machine; there's no reason to resort to parlour tricks... https://gist.github.com/igor47/7228586
https://gist.github.com/alexchow/7228746
Try the case: ([2,5,1,2,3,4,7,7,6,3,5], 12)
That just doesn't speak well of this particular PhD. The one-pass solution is rather obvious. I hate puzzle-based interviews with passion, but this is actually a very reasonable question and it does help to tell apart people with "theoretical" computer science skills from those with a bit more practical experience.
Google cache: http://webcache.googleusercontent.com/search?client=ubuntu&c... It's off-line for me and asking something about installing a server.
you could solve this with a simple state machine; there's no reason to resort to parlour tricks... https://gist.github.com/igor47/7228586
Your solution doesn't work when there is more than one "puddle": https://gist.github.com/alexchow/7228746 Try the case: ([2,5,1,2,3,4,7,7,6,3,5], 12)
It was depressing to me and I felt down for quite a bit, mainly because on the second phone screening I just couldn't do the coding task asked. My mind went blank and I probably sounded like a 5 year old struggling through the simplest of questions.
It's my own fault though, I just got more and more stressed over the preceding weeks reading algorithms textbooks and "CareerCup" tests I think I just burned out.
I totally understand that top companies like Amazon and Google can afford to be ruthless and choosy in their interview process, after all, they're top companies for a reason, but I guess it just wasn't for me
No offence to Twitter, but this is a seriously bad way of hiring developers. What are you trying to recruit mathematics scholars as developers? When will companies like Twitter learn not all great developers are math geniuses? I didn't even get a college education to get where I am, I failed maths in school as well, but I can code, so what does that mean? I think it means nothing in the greater scheme of things. By t…
In fact I would be thrilled if they are recruiting for math people. They are not. I have been in the job market for a while now and recruiters literally stop listening when they don't hear "CS" in the first sentence.
This question involves an "a-ha" moment (for the linear-time solution) and was thus banned from interviews at Google last year. Don't use questions involving eureka moments. They reveal nothing about the candidate. Edit: It should be noted that this question was used for a long time at Google, Microsoft, and many other places. It's a terrible question.
Two-pass solution is obvious, just look at the final state. Once you are at that, the one-pass is a run-of-the-mill optimization of switching from accumulating and then processing the state to doing it all in parallel. The ability to recognize when this is doable is a good way to tell someone who's done it before (in some other context) from those who merely wrote a functional prototype of Tic-Tac-Toe in TurboPascal.
What is important to understand here is that these processes are highly variable and there is an element of luck involved. It's just the nature of a human-driven process and a complicated organization.