Microsoft Online Assessment Experience (L61/L62) - SDE 2
Anonymous User
285

Question 1: The Prima Donna Hackathon Team

The Narrative

In the bustling tech hub of Silicon Valley, an ambitious coordinator is trying to assemble the ultimate dream team for an upcoming mega-hackathon. There are developers available, uniquely ranked by their precise skill levels from to . On paper, a massive team sounds perfect—but there's a catch: these developers have massive egos and hypersensitive insecurities.

Every single developer has strict social boundaries about who they will share a table with. Specifically:

  • The -th developer will instantly walk out if they look down and see too many beginners. They demand that at most lowerSkill[i] team members have a lower skill level than them.
  • Simultaneously, they can't stand being overshadowed by too many experts. They insist that at most higherSkill[i] team members have a higher skill level than them.

If even one chosen developer feels uncomfortable with the final team line-up, they won't sign up. Your mission as the coordinator is to find the absolute largest group of developers you can bring into the room such that everyone sits down, looks around, and happily agrees to stay.

A Day in the Selection Room

Imagine you have 5 developers. Their tolerance thresholds are:

  • lowerSkill = [1, 3, 2, 2, 2]
  • higherSkill = [2, 2, 1, 1, 3]

If you greedily pick all 5, the expert at rank 5 looks down, sees 4 people below him, screams "Too many amateurs!" (since his limit was 2), and leaves. After a series of dramatic exits, you realize the magic number is 3. By inviting only developers 1, 3, and 4, a perfect harmony is achieved. Developer 1 tolerates the 2 superiors; Developer 3 is perfectly balanced with 1 junior and 1 senior; and Developer 4 happily accepts having 2 juniors below him.


Hints & Topics

  • Topics: Binary Search, Greedy, Sequence Matching
  • Hint 1: Instead of guessing who fits, what if you guess the final team size first? The problem asks for a maximum, and checking whether a target size is achievable follows a predictable, monotonic pattern.
  • Hint 2: Because skills are hard-coded to the developers' original order, you can't rearrange their hierarchy. Try checking a fixed team size by marching from left to right, greedily locking developers into slot 1, slot 2, up to slot the moment they satisfy the local boundaries.

Question 2: The Fuel Smuggler of Hackerland

The Narrative

Welcome to the lawless roads of Hackerland, a country made up of isolated cities interconnected by a web of bidirectional highways. You are a legendary long-haul trucker tasked with delivering a high-value cargo from City to City . Your rig is a mechanical marvel: it has an unlimited fuel tank capacity, but it drinks fuel like water. Traveling down any highway requires a specific number of fuel units, given by the road's weight.

The problem? The corporate fuel syndicates control the prices, and every city charges wildly different rates per unit of fuel, tracked in the global arr index. Some cities are dirt cheap hubs; others are highway robbery.

Fortunately, since your fuel tank is infinite, you can play the market. If you know an expensive mountain pass is coming up later in your journey, you don't have to buy gas at the base of the mountain. If you stumbled across a cheap fuel haven three towns ago, you could have filled your infinite tank to the brim right then and there to cover the rest of your trip!

Your goal is to map out a route and a refueling strategy that gets you to your destination with the absolute minimum dent in your wallet. If the highways are broken and there's no path forward, you'll have to radio in a failure.

A Logbook Entry

You need to get from City 3 to City 2. The local prices are:

  • arr = [9, 11, 3, 2, 10] (City 4 is incredibly cheap at , while City 3 is ).

You start at City 3. You could drive straight through the expensive tollways, but your GPS plots a clever detour: .

  1. At City 3, you buy exactly enough fuel ( units) to get you through cities 5 and 1 all the way to City 4. Cost: 3 \times \3 = $9$.
  2. Once you roll into City 4, you realize gas is an absolute steal at \299 \times $2 = $18$27$**.

Hints & Topics

  • Topics: Graph, Shortest Path, Dijkstra's Algorithm, Floyd-Warshall
  • Hint 1: Since your tank is infinite, your current fuel price is effectively the cheapest price you've encountered anywhere along your path so far.
  • Hint 2: Look at how small the number of cities is. This small world allows you to expand your navigation states. Try running a shortest-path algorithm where your location state isn't just current_city, but a pair: (current_city, cheapest_fuel_found_so_far).
  • Hint 3 (Alternative Structural Shortcut): What if you bypass the intermediate steps entirely? Use an all-pairs shortest path algorithm to find the absolute shortest structural distances between all cities. Then, treat the trip as a series of direct leaps from one refueling hub to another, paying the source hub's rate for the entire leap.
Comments (0)