• InstaByte
  • Posts
  • 🤩 All FAANGs asked this problem

🤩 All FAANGs asked this problem

ALSO: How to design YouTube

Welcome back, Interview Masters!

This week we’re gearing up to solve a timeless problem, asked by all FAANGs.

In today’s newsletter, we’ll cover:

  • ‘Container with most water’ problem

  • How to design YouTube

Read time: under 4 minutes

CODING CHALLENGE

Container With Most Water

You are given an integer array height of length n. There are n vertical lines drawn such that the two endpoints of the ith line are (i, 0) and (i, height[i]).

Find two lines that together with the x-axis form a container, such that the container contains the most water.

Return the maximum amount of water a container can store.

Notice that you may not slant the container.

Example 1:

Input: height = [1,8,6,2,5,4,8,3,7]
Output: 49
Explanation: The above vertical lines are represented by array [1,8,6,2,5,4,8,3,7]. In this case, the max area of water (blue section) the container can contain is 49.

Solve the problem here before reading the solution.

REFER FOR THE WIN

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

Spoiler Alert: a new reward is launched!

📌 Check your referrals status here.

Share your referral link on LinkedIn or with your friends to unlock the treasures quicker!

SOLUTION

To solve this problem, we will use a two-pointer approach. Two pointers represent the current walls of the container. Initially, we put the first pointer at the beginning and the second pointer at the end of the array.

If you look closely, the shorter wall decides how much water a container can hold. To calculate the water that the current container can hold, we multiply the height of the shorter wall by the distance between the two walls.

Then, we move the pointer at the shorter wall inwards hoping to find a taller wall and increase water that can be stored.

We will update the maximum area as we do this. This process continues until the two walls come together.

SYSTEM DESIGN EXPLAINED

How to design YouTube?

Source: Tenor

Let’s dive into the high-level design for a simplified Youtube system.

The key requirements include fast video uploads and smooth streaming. We also want the system to be highly available.

The system mainly consists of a content delivery network (CDN), transcoding servers, and databases for video and metadata storage.

Videos are uploaded in chunks and transcoded into multiple formats for different devices and bandwidths. Metadata like titles and descriptions are stored in a sharded and replicated database. CDNs deliver videos and cache the popular ones. Check out this article for more details.

NEWS

This week in the tech world

Source: Analytics Vidhya

OpenAI releases GPT-4o: OpenAI released a new AI model called GPT-4o, which is faster and works across text, video and audio. This update brings GPT-4 capabilities to free users of ChatGPT for the first time. They also launched a desktop app and new features to make AI interaction more natural.

Google I/O AI reveals: Google showcased its latest AI products at its I/O developer conference. The announcements highlight Google's focus on AI competition, with updates to its powerful language model Gemini and new search features like AI Overviews. Project Astra, a prototype AI assistant, is another highlight, aiming to provide real-time conversation similar to Iron Man's Jarvis!

Uber Go-Get announcements: Uber unveiled several features to broaden its reach. Riders can now book budget-friendly shared shuttles for airports and events. Caregivers can even manage rides and deliveries for dependents through the app. To sweeten the deal, Uber Eats partnered with Costco, offering delivery with member discounts, and introduced "Lists" for sharing restaurant recommendations.

Instagram Co-founder joins Anthropic: Mike Krieger, who helped grow Instagram to 1 billion users, is now Chief Product Officer at Anthropic. Anthropic develops chatbots like Claude, which competes with OpenAI’s ChatGPT. The company is backed by Amazon, Google and Salesforce and is looking to expand its reach in the enterprise and consumer AI market.

OpenAI shakeup: Ilya Sutskever, co-founder of OpenAI, is leaving the company to pursue a personal project. He will be replaced by Jakub Pachocki as chief scientist. This news follows a period of internal conflict at OpenAI, including Sam Altman's ouster and reinstatement.

Reddit soars on meme stocks frenzy: Reddit's stock price surged after retail investors piled into meme stocks again. This follows the online reappearance of "Roaring Kitty," the investor who fueled the meme stock craze in 2021. Shares of GameStop and AMC, popular meme stocks, also doubled in price over the past two days.

Tech giants invest in France: French President Emmanuel Macron's efforts to position France as an AI leader are paying off. Microsoft pledged $4.3 billion to expand its cloud and AI infrastructure, while Amazon will invest $1.3 billion to create jobs and boost its presence in the country.

POLL

Results from last week

This one’s for you

What's your go-to source for coding help?

Login or Subscribe to participate in polls.

BONUS

Just for laughs 😏

Source: Giphy

YOUR FEEDBACK

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.

Review of the week

Until next time, take care! 🚀

Cheers,