
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):
- Position Requirements: Google Junior Software Engineer position requires at least one year of relevant experience.
- OA Time: Candidates receive a 30-minute long online assessment test (OA) with a deadline of June 1, 5:45 a.m. (Pacific Time).
- OA content: All 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 = ?
Topic description: Given a sorted array arr = [1, 2, 3, 10, 11, 12] and a target value mFind the distance m nearest K=3 Elements.
Clarification. The interviewer asks the question: if the array is [1, 2, 4, 5]The target value is m = 3If you need to select 2 and 4, should you select 1 or 5 for the remaining element?
Candidates: Just choose any one.
Confirmation of Candidate and Interviewer:
- The resulting array size is
3. - No additional sorting is required.
- Use binary search And two-pointer method (computing) Problem solving.
Code structure and solution:
Algorithmic Thoughts:
- Dichotomous search: Find the closest element near the target value.
- Initialization
leftAndrightPointer. - 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
leftAndrightvalue 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):
# 二分搜索找到最接近的元素
left, right = 0, len(arr) - 1
while left < right:
mid = left + (right - left) // 2
if arr[mid] < m:
left = mid + 1
else:
right = mid
# 双指针扩展
closest = left
left, right = closest - 1, closest
result = []
for _ in range(k):
if left >= 0 and (right >= len(arr) or abs(arr[left] - m) <= abs(arr[right] - m)):
result.append(arr[left])
left -= 1
else:
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
Google OA | Leetcode
2024 Google OA
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.