is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.
CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.
Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.
Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.
I found this one a little tricky. Took me a bit of experimentation to work out the transition between the number of digits.
There may be more efficient patterns, but this worked for me.
As others have mentioned, the basic pattern is:
10 x single digits (or 9 plus a 0 if it helps you)
90 x double digits
900 x triple digits
and so on.
Another way of thinking about that is
1 + 9 x 10**0 + 9 x 10**1 + 9 x 10**2 ... + 9 x 10**n
So to work out how many digits are in the number you're grabbing the index of:
you have n+1 digits where n is the power you're applying to 10 i.e.(9 x 10**n)
so applying that to our index,
index =
0-9 - 1 digit (10)
10-189 - 2 digits (2x90 + 10)
190 - 2890 - 3 digits (3x900 + 2x90 + 10)
Now to work out specifically which number we're dealing with, we take the index plus the count of numbers that have come in each band before, then divide by the number of digits
For example, let us say we want the number at index 203
we had 10 matches up to 10, 100 matches up to 190 so we add 110 to 213 then divide by three to get the actual number
323 / 3 = 107
use mod 3 to find out which position in the number you're returning
107 % 3 = 2
That being the case, we return 7 (index 2 of 107)
Here's the implementation in ruby:
- Ben February 07, 2013