Just finished it recently Adobe SDE OA (HackerRank), to be honest: the repetition rate of the question bank is not low, and the probability of getting the same set is very high. This OA has a total of 3 lines of coding, one of which is fixed in Python. If you are preparing for Adobe, this set must be saved.
OA basic information
- Platform: HackerRank
- Number of questions: 3 Coding
- Language: 1 question requires Python
- Difficulty: Moderate, but easy to overturn in details
T1 | Minimum absolute difference pair (high frequency)
Question meaning
Given an array of non-repeating integers, find all pairs of numbers with the smallest absolute difference. Each number pair is required to be sorted internally in ascending order, and the final result is output in ascending order of the first element.
Ideas
First sort the array so that the smallest difference can only appear in adjacent elements. Then linearly traverse the sorted array: when encountering a smaller difference, clear the result and update the minimum difference, and when encountering the same difference, directly add the result.
Easy to step on
Pay attention to clearing the old results in time when updating the minimum difference value, and the output sequence must be processed as required, otherwise it is easy to make errors.
T2|Temperature operation reaches the maximum value
Question meaning
Given a starting temperature x, a target temperature y, and up to z operations (each can be +1 or -1), the maximum temperature that can be reached in the process is required before finally reaching y. If y cannot be reached, -1 is returned directly.
Key to problem solving
The idea is actually very straightforward, with three main steps:
- Judgment of reachability or unreachability: If z is less than |x – y|, it means that the number of operations is not enough, and -1 is returned directly.
- Parity judgment: The parity of the number of operation steps and the distance must be consistent, otherwise the actual number of available steps K = z – 1; if they are consistent, K = z.
- Go high strategy: First rush up as much as possible, then turn around and return to y. The maximum temperature can be directly calculated as (x + y + K) / 2.
Many people fail at this question. It's not that they can't do it, but they don't pay attention to the parity, or they think of the strategy too complicatedly.
T3 | Different substrings of length k
Question meaning
Given a string Password And integers K, the statistics of all lengths are K The number of different substrings.
Ideas
Can be used directly in Python Set Implementation: Traverse from index 0 to Len(password)-k, the length of each cut is K Substrings and join Set, and finally return Len(set) That’s it. Boundary cases need to be considered Len(password) < k, returns 0 at this time.
Why is it easy to fail when answering questions?
Many students are actually capable during the question writing stage, but they make mistakes in the formal OA due to nervousness and disrupted rhythm.
Many students will choose Programhelp in key OA fields. OA traceless assist : If you are preparing for OA from Adobe, Google, Amazon and other companies, especially if time is tight and the number of questions is concentrated, you can contact us.