Try cracking this Microsoft problem

ALSO: How Uber calculates ETA for riders

Welcome back, Interview Masters!

Are you ready for a coding challenge? We are going to spice it up today with a medium difficulty question.

In today’s newsletter, we’ll cover:

  • Product of Array Except Self

  • How Uber calculates the estimated time of arrival for riders

Read time: under 4 minutes

CODING CHALLENGE

Product of Array Except Self

Given an integer array nums, return an array answer such that answer[i] is equal to the product of all the elements of nums except nums[i].

The product of any prefix or suffix of nums is guaranteed to fit in a 32-bit integer.

You must write an algorithm that runs in O(n) time and without using the division operation.

Example 1:

Input: nums = [1,2,3,4]
Output: [24,12,8,6]

Example 2:

Input: nums = [-1,1,0,-3,3]
Output: [0,0,9,0,0]

Solve the problem here before reading the solution.

SOLUTION

To solve this problem efficiently without using division, we’ll use two additional arrays.

First, we'll create a “left_products” array where each element at index i represents the product of all elements to the left of nums[i].

Then, we'll create a “right_products” array where each element at index i represents the product of all elements to the right of nums[i].

Finally, we'll compute the result array “answer” by multiplying corresponding elements from left_products and right_products.

Time complexity of this solution is O(n).

SYSTEM DESIGN EXPLAINED

How Uber Computes ETA at Half a Million Requests per Second

Uber uses a graph representation of maps, where roads are edges and intersections are nodes. They partition the graph and pre-compute the best paths within each partition to handle a large number of ETA requests efficiently.

Traffic information and real-time GPS data are also used to improve accuracy. Even a small improvement in ETA can lead to significant benefits for Uber, as millions of trips are made daily. You can read the full article here.

NEWS

This Week in the Tech World

DeepMind Powerhouse Joins Microsoft: Mustafa Suleyman, co-founder of DeepMind, is now heading Microsoft's new AI unit. This move suggests Microsoft is ramping up its efforts to compete with Google and OpenAI in the AI race.

Nvidia's AI Edge: Nvidia's stock price jumps after unveiling their new Blackwell AI chips. These chips, launching later this year, aim to further establish Nvidia as a leader in the AI hardware market.

AI in the Workplace: Devin, the AI engineer, sparks debate on job replacement vs productivity gains.

India's Chip Ambitions: India sets a bold goal to become a global chip-making powerhouse within five years. This ambitious plan could reshape the global chip supply chain if successful.

Alphabet benefits from Gemini AI buzz: Alphabet, Google's parent company, sees a 4.6% stock rise following reports that Apple might license Google's controversial Gemini AI. This potential deal could be a significant revenue boost for Google AI.

Bonus: Google just announced a date for the developer conference Google I/O on May 14, 2024. Expect a lot of Gen AI topics, with live streams and on-demand technical sessions available.

POLL

This one’s for you

What's more important for you when choosing a job?

Login or Subscribe to participate in polls.

BONUS

Just for laughs 😏

Source: @dev_humor on X

Until next time, take care!

Cheers,

👋 Hey! Share your referral link with friends to unlock Hidden Treasures:

📌 Your referral link: https://www.interviewmaster.io/subscribe?ref=PLACEHOLDER

Share your referral link on LinkedIn or with your entire class to unlock the treasures quicker.

NEXT IN CODING CHALLENGE

Two Sum

Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.

You may assume that each input would have exactly one solution, and you may not use the same element twice.

You can return the answer in any order.

Join us next week to find out the solution.

SHARE YOUR THOUGHTS ON THIS EDITION

What did you think of this week's email?

Your feedback helps us create better emails for you!

Login or Subscribe to participate in polls.