In the hearts of many programmers, Google has always been the ultimate dream station. Not only does it have the world's leading engineering system and technical standards, it is also known for its extremely high recruitment threshold.
Many students are often confused when preparing for the Google Software Engineer position: what is the interview process? What is the pattern of questions? What do you need to focus on preparing? This blog will provide you with a systematic compendium of Google's interview process, question distribution, and classic high-frequency questions, taking you to stand on the shoulders of giants to prepare for the battle and impact Google dream offer!
Google's SDE job requirements and online assessment tests (OA):
- Job Requirements: Google's Junior Software Engineer position requires at least one year of relevant experience.
- OA Time: Candidates receive a 30-minute-long online assessment test (OA) due June 1 at 5:45 a.m. (Pacific Time).
- OA Content: All are personality tests. Candidates are advised to answer in a sincere and positive manner to avoid wasting valuable opportunities.
Interview question: Finding the K closest elements
Given a sorted array arr = [1,2,3,10,11,12], find k=3 closest elements around target m = ?
Question Description: Given a sorted array arr = [1, 2, 3, 10, 11, 12] and a target value m, find the nearest k=3 elements to m.
Clarification: The interviewer asks the question: if the array is [1, 2, 4, 5] and the target value is m = 3, and you need to select 2 and 4, should you select 1 or 5 for the remaining element?
Candidates: Any one will do.
Confirmation of Candidate and Interviewer:
- The resulting array size is
3. - No additional sorting is required.
- Use dichotomous search and double pointer method to solve the problem.
Code structure and solution:
Algorithmic Thoughts:
- Dichotomous search: Find the closest element near the target value.
- initialization
leftrespond in singingrightPointer. - utilization
mid = left + (right - left) // 2Determine the direction of movement. - Records the index of the element closest to the target value.
- initialization
- The two-pointer method:
- Starting from the nearest element index and expanding to both sides.
- comparisons
leftrespond in singingrightvalue of the pointer, selecting the element that is closer to the target value. - Updates the pointer and adds the elements to the result set.
- Complexity Analysis:
- Bisection search complexity: O(log n).
- Double pointer extension complexity: O(k).
- Total complexity: o(log n + k).
def find_closest_elements(arr, k, m).
# Dichotomous search to find closest elements
left, right = 0, len(arr) - 1
while left < right.
mid = left + (right - left) // 2
if arr[mid] = 0 and (right >= len(arr) or abs(arr[left] - m) <= abs(arr[right] - m)).
result.append(arr[left])
left -= 1
result.append(arr[right] - m): result.append(arr[left])
result.append(arr[right])
right += 1
return sorted(result)
Interview Summary and Recommendations:
- Key Points:
- Demonstrate proficiency in dichotomous searching and the two-pointer method.
- The code is clearly structured and commented to aid the examiner's understanding.
- Ensure that boundary cases are handled correctly (e.g., pointer out of bounds).
- Post-interview communication:
- Demonstrate interest in the position and ask about the content of future projects for which you will be responsible.
Reference
We provide services for writing online assessments (OA), proxy interviews, and interview assistance. For the OA writing service, we will ensure that you achieve a perfect score. Contact us Now to make an appointment.