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.
Algorithm is as follows:
- Elena April 10, 20131) Go from i = 0 to i = n-2 of given array
2) For every i, get "hash" of elements A[i],A[i+1],A[i+2].
Hash is generated this way: elements A[i],A[i+1],A[i+2] are sorted and glued together with some separator. So. for {1,2,3} and {3,2,1} and {2,1,3} "hash" will be the same - "1|2|3".
3) Remember "hash" and its position in hash table: HashPositions["1|2|3"].push(i);
4) At the end, go through all HashPositions, and those which have only 1 position, are unique subsets.
Complexity:
1) We loop from 0 to n-2 (n-2 steps)
2) On every step we sort 3 elements (it takes constant time C)
3) At the end, we go through all hashes (maximum n-2 hashes)
So, complexity is C*(n-2) + (n-2) = (C+1)(n-2) = O(n)
Speedup: if we have sorted three elements A[i],A[i+1] and A[i+2] and need to get sorted next three elements A[i+1],A[i+2],A[i+3] we should not sort them again. We should just remove A[i] and insert A[i+3] into previous sorted array. It works faster.