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.
Here is my code for this one:
- impromptuRong August 08, 20151. Sort the array: O(nlgn)
2. Search the array and check the maximum No. can be reached with 1~preVal.
(1). If the No. in array is equal to preVal, update maxreach, look at next.
(2). If the No. in array is bigger than preVal, update maxreach, put this No. into result.
Python code:
def leastNo(array, N):
if array is None:
array = []
array.sort()
maxreach, preVal, index, res = 0, 0, 0, []
while maxreach < N and index < len(array):
if array[index] <= 0:
continue
if array[index] > preVal + 1:
res.append(preVal + 1)
else:
index += 1
maxreach += preVal + 1
preVal += 1
while maxreach < N:
res.append(preVal + 1)
maxreach += preVal + 1
preVal += 1
return res
testcase:
leastNo(None, 10)
[1,2,3,4]
leastNo([], 6)
[1,2,3]
leastNo([3,2,1], 10)
[4]
leastNo([3,1,4], 7)
[2]
leastNo([3,1], 6)
[2]
leastNo([8,4,2,3,1,9], 10)
[]
I don't know how to maintain white space, sorry...
Looking for better ideas~ Thanks!