Databricks SDE OA interview sharing|70min four questions, overall medium difficulty

46 Views
No Comment

Today’s sharing is from a classmate who is studying for a master’s degree in computer science in North America. He usually takes about 200+ questions on LeetCode, and his target position is Databricks Software Engineer. This test lasts for 70 minutes and has a total of 4 questions. The overall difficulty is medium. The first two questions are close to LeetCode easy and can basically be completed relatively quickly. The last two questions are medium difficulty and require a little more thinking. Let’s sort out the overall structure and question types of this OA, as a reference for students preparing for Databricks SDE later.

Databricks SDE OA interview sharing|70min four questions, overall medium difficulty

Odd and even position elements and comparison

Question description

Given an array of integers Numbers, comparing the sum of elements at even positions (0-based index) with the sum of elements at odd positions:

  • If the sum of the elements at even positions is greater, return "even"
  • If the sum of elements at odd positions is greater, return "odd"
  • If the two are equal, return "equal"

Illustrate

  • The position here is the 0-based index (that is, the first element of the array is at position 0).
  • Example:
    1. Numbers = [1, 2, 3, 4, 5]
      • Even positions (0, 2, 4):1 + 3 + 5 = 9
      • Odd positions (1, 3):2 + 4 = 6
      • Because 9>6, so the output "even"
    2. Numbers = [-1, 4, 3, -2]
      • Even positions (0, 2):-1 + 3 = 2
      • Odd positions (1, 3):4 + (-2) = 2
      • Because 2 = 2, so the output "equal"
  • The time complexity does not exceed O(n²) It can be passed (n is the length of the array).

Unix command execution count statistics

Question description

In Unix systems, there are two common ways to execute commands:

  1. Enter the command name directly, for example Cp,Ls,Mv;
  2. Enter ! Instructions in the format used to repeatedly execute the index (1-base index) command after the start of this session.

For example, the user enters the following commands in sequence:

LsCpMvMvMv!1!3!6

  • !1 Command 1 will be executed repeatedly Ls
  • !3 Command 3 will be executed repeatedly Mv
  • !6 Order 6 will be executed first !1, thus triggering the execution of Ls

Given a sequence of commands Commands, where each command can only be "cp","ls","mv" Or "!" Format.

Please calculate Cp,Ls,Mv The total number of times the three commands are actually executed, and returns the form: [cp times, ls times, mv times] Array of integers.

Note: It can be passed if the time complexity does not exceed O (n³).

Statistics of the longest continuous housing segment

Question description

You are monitoring building density in a residential area. The residential area can be viewed as a number line, and houses can only be built at a location if at least one adjacent point is unoccupied. Initially, there are no houses in the area.

Given an array of integers Queries, indicating in sequence the locations of new houses to be built. After each house is built, you need to find the longest continuous length of house segments in the current area.

Returns an array of integers where each element corresponds to Queries The longest continuous segment length of each house in the building after it is built.

Notice:

  • All Queries The locations of the houses in are all unique;
  • It is guaranteed that no new houses will be built where there are existing houses at adjacent points to the left and right.

Example

Enter:Queries = [2, 1, 3]

Output:[1, 2, 3]

Sum of digital strings in reverse order bit by bit

Question description

Given two numeric strings A And B, calculate the sum of each bit according to the following rules and return the result string:

  • Starting from the end, add the first two strings I Adding digits;
  • If the first of one of the strings I If the bit does not exist, directly take the first bit of another string. I Bit as sum;
  • Concatenate the sum of all bits in order into a new string and return it.

Example

Sheet

Enter A Enter B Output Illustrate
"99" "99" "1818" From back to front:9+9=18,9+9=18 → Spliced ​​into "1818"
"11" "9" "110" From back to front:1+9=10,1(The second string has no second digit) → concatenated into "110"

A bit of real advice

Finally, the student was successfully promoted to VO. In fact, it’s not that many students can’t do the questions, but that it’s easy to get stuck in the OA environment: they suddenly find bugs in the middle of writing, fail to handle boundary conditions well, or start to panic when time is tight. This situation is particularly common in the 70-minute four-question OA. So many people will look for it in advance Interview assistance Preparing together is often just one click away, which is much more efficient than being stuck thinking about it for half an hour.

author avatar
Jory Wang Amazon Senior Software Development Engineer
Amazon senior engineer, focusing on the research and development of infrastructure core systems, with rich practical experience in system scalability, reliability and cost optimization. Currently focusing on FAANG SDE interview coaching, helping 30+ candidates successfully obtain L5/L6 Offers within one year.
END
 0