[SWE] OA 2025 start – 7 Mar (generic)

We want to store one million "interesting" numbers in a data structure and are choosing between a doubly linked list and an array (size 1), and are generated (and thus stored) in sorted order. If we only consider the numbers stored in our data structure to be in the range from 0 to (2⁶⁴ - 1), how long does it take for each data structure to determine if a particular number is "interesting" of either data structure, and ignore any additional overheads. Use average case performance.

Pick ONE option

  • ( ) It will take us 140 ns for the array and 3.5 million ns for the linked list.
  • ( ) It will take us 140 ns for the array and 7 million ns for the linked list.
  • ( ) It will take us 3.5 million ns for the array and 3.5 million ns for the linked list.
  • ( ) It will take us 3.5 million ns for the array and 7 million ns for the linked list.
  • ( ) It will take us 3.5 million ns for the array and 140 ns for the linked list.
  • ( ) It will take us 7 million ns for the array and 140 ns for the linked list.

  1. Question 7

You have developed a scoring system for positive integers that works as follows:

  • +4 points for every 9 found in the number. For example, 9591 would score 8 points.
  • +5 points for each pair of consecutive 1s. If there are more than two 1s in a row, add +5 for each additional 1, since it makes an additional pair (for example, four consecutive 1s gives +15).
  • +N² points for a sequence of length N (N >= 1) where each digit is 1 more than the previous one. For example, 19678562 (9-878-56-2) would be 1² + 3² + 2² + 1² = 15 points.
  • +1 if the entire number is a multiple of 7.
  • +2 for each even digit (note that 0 is even).

Each component of the score is evaluated separately, so a given digit may contribute to more than one component. For example, the number 789 would score 9 for the sequence of length 3, 2 for one even digit, and 4 for the '9' digit, for a total of 15 points.

Write a function compute_number_score that computes (and returns) a score for an integer passed to it. The number will be in the range 0 <= number < 1000000000.


Question 8

Suppose we want to monitor how locks are used in our system. As the first step, we log moments of acquire and release for each lock in the following format:

  • ACQUIRE X
  • RELEASE X

where X is some integer ID (1 <= X <= 1,000,000) of the lock.

All locks must be released in the reverse order of acquiring them; for example, this is a correct event sequence:

  1. ACQUIRE 364
  2. ACQUIRE 84
  3. RELEASE 84
  4. ACQUIRE 1337
  5. RELEASE 1337
  6. RELEASE 364

However, the following sequence violates this rule, because lock 84 is still acquired while releasing lock 364:

  1. ACQUIRE 364
  2. ACQUIRE 84
  3. RELEASE 364
  4. RELEASE 84

It's also dangerous to leave locks acquired after application termination, as other processes in the system may be blocked while waiting on them, so such sequence is incorrect, too.


  1. Question 9

Complete the blanks in the following question with the appropriate answer.

Alice P. Hacker has two types of memory that she’s using to build her system to store her objects. The first type, type A, is extremely fast, but it’s expensive and she doesn’t have much of it. She has 10GB of type A memory that can be used to store objects, and reading an object from this memory takes 5ms.

The second type of memory, type Z, is a lot slower, but it’s cheap, and so Alice bought a lot of it. She has 1TB of the second type of memory that she can use to store objects, and reading an object from this memory takes 200ms.

Alice decides she’s going to build a system where she keeps all of her objects in the second type of memory, and then also keeps copies of some of those objects in the first type so that she can do some of her reads more quickly. Alice has 2048 objects, all of the same size, which use up all of her second type of memory storage. Alice decides to analyze different ways to pick and choose what she keeps in her type A memory, and how they affect her expected object read performance.

Please round all answers to 3 decimal places.

If Alice is naive and decides to randomly fill her type A memory with objects and every read is equally likely to randomly select objects out of the 2048 (in ms)?
______ ms

Alice now runs a workload where she reads 20 objects per minute. 50% of the objects she reads are objects she’s seen in the past 30 seconds, and the other 50% of the objects are randomly chosen from the full 2048. Using the same naive strategy as before, what is her expected average read time for an object with this workload?
______ ms

Alice tries to improve her performance. She decides that, every time she reads an object, if it is not in her type A memory, she will put it there. When she needs to remove something, she will remove the thing that she read least recently.

What is Alice’s average read time per object in the best case scenario?
______ ms

What is Alice’s average read time per object in the worst case scenario?
______ ms


我们长期稳定承接各大科技公司如TikTok、Google、Amazon等的OA笔试代写服务,确保满分通过。如有需求,请随时联系我们。

We consistently provide professional online assessment services for major tech companies like TikTok, Google, and Amazon, guaranteeing perfect scores. Feel free to contact us if you're interested.

Leave a Reply

Your email address will not be published. Required fields are marked *