This time around, we're going to share Google Internet company 26 Intern OA experience, the overall process is very smooth, two questions are once AC, after the end of the time left to do a lot of time to check. Google's OA questions are considered to be a more classic type, the difficulty is not perverted, but the implementation of the need to be careful.
The most critical point is: although this kind of OA questions can be found in the question bank, but when the real battle, many students will be nervous or not in place to deal with the details, resulting in incomplete AC. So this time, I was able to pass in seconds, not only because of my own algorithmic skills, but also thanks to Programhelp's remote and seamless on-line assistance - I was able to quickly clear my mind when I got stuck, and ensure that the test case 100% was passed in its entirety.
The questions are shared below.
Question 1: Longest Harmonious Subsequence
Problem.
Given an integer array, find the length of the longest harmonious subsequence where the maximum value and the minimum value differ exactly by 1.
Example.
Input: [1,3,2,2,5,2,3,7]
Output: 5
Explanation: The subsequence [3,2,2,2,2,3] is harmonious.
Thought Analysis:
The key to this question is that the difference between the maximum and minimum values is only 1. In other words, the entire subsequence can only consist of two adjacent numbers, such as 2 and 3.
- Step 1: Count the number of occurrences of each number using a hash table.
- Step 2: Iterate through the hash table, for each number
XInspectionx+1Whether or not it exists, and if so, calculate thecount[x] + count[x+1]. - Step 3: Take the maximum of all combinations as the answer.
The implementation should pay attention to boundaries, for example, when the array has only the same elements, the result should be 0. Overall this is a basic hash statistics + traversal question.
Question 2: Permutation in String
Problem.
Given two strings s1 and s2, return true if s2 contains the permutation of s1.
Example.
Input: s1 = "ab", s2 = "eidbaooo"
Output: true
Explanation: "ba" is a permutation of "ab".
Thought Analysis:
This is the classic sliding window problem:
- First count the frequency of each character in s1.
- Then a sliding window of length equal to s1 is maintained on s2, and each time a new character is entered and an old character is removed, the frequency table is updated.
- Compare it with the frequency table of s1 after each update, and return true if it is consistent.
- Returns false if the entire scan ends without a match.
The detail is that the window update should be written cleanly, otherwise it is easy to make mistakes. This question is basically a giveaway in OA, but it is also the easiest to lose points because of small bugs.
Practical experience
I was given plenty of time for this OA. It took me about 20 minutes to finish the first question, 25 minutes to finish the second question, then 10 minutes to add the test case, and another 10 minutes or so to check the code.
Google's OA will not intentionally jam your time, but to see if you can implement the basic algorithm idea completely, bug free. so in my opinion, details and stable mindset is more important than the so-called "difficult algorithms".
Google 26 Intern OA summarize the pattern of questions
Combined with this and previous tutoring of students, there are a few obvious patterns in Google OA:
- Examining basic algorithmic templates: Hash tables, sliding windows, and double pointers, are high-frequency occurrences.
- Attention to code details: Boundary conditions, frequency statistics, window updates, and other places are easy to miss.
- Moderately difficult but requires stability: Not as tricky as hedge fund or quant interviews, but definitely no room for carelessness.
So the best way to prepare for Google OA is to familiarize yourself with these types of questions ahead of time and practice the templates until you can write them quickly and accurately.
The secret to getting through a big factory OA without panicking
Many students have no problem thinking when brushing up, but once they enter the OA environment, they are prone to it:
- Ideas didn't fully develop, and halfway through the writing I realized I was going in the wrong direction;
- The boundary cases were not fully considered and the last few hidden cases did not pass;
- The time allocation was uneven and the second question timed out before the debug was finished.
Our Programhelp's remote, no-frills online assistance solves these pain points:
- no trace operation: Invisible assistance throughout the exam environment to ensure safety.
- 100% Test case passed: If it doesn't pass, there is no charge.
- Real-time voice alerts: When stuck at key points, ideas are nudged to avoid wasting time.
- pre-testing drill: For Google, Amazon, Meta and other companies common question types, simulation of the actual battle in advance, the real exam will be able to easily get.
This time Google OA I can successfully pass in seconds, but also because of this set of guarantees, so that I do not panic in the actual battle, the code once molded. But if you don't want to be alone, and want to pass the test in one go, then Programhelp's OA No Trace Online Assistance will be your safest choice. After all, the opportunity is precious, and it would be a real relief to make sure 100% passes.