🔥 What Meta asked 102 times

ALSO: Forward Proxy vs Reverse Proxy

Welcome back, Interview Masters!

Meta asked this question 102 times in the last 6 months. Get ready for some “powerful” math!

In today’s newsletter, we’ll cover:

  • Pow(x, n) problem

  • Difference between Forward Proxy and Reverse Proxy

Read time: under 4 minutes

CODING CHALLENGE

Pow(x, n)

Implement pow(x, n), which calculates x raised to the power n (i.e., xn).

Example 1:

Input: x = 2.00000, n = 10
Output: 1024.00000

Example 2:

Input: x = 2.10000, n = 3
Output: 9.26100

Example 3:

Input: x = 2.00000, n = -2
Output: 0.25000
Explanation: 2-2 = 1/22 = 1/4 = 0.25

Solve the problem here before reading the solution.

If you want to know the top interview questions to study to crush your tech interviews, check out our guide 🚀 Interview Master 100.

SOLUTION

Before we get into the solution, let's make sure you understand the terminology. x is called the base, whereas n is called the exponent.

We'll handle negative exponents by converting them to positive and taking the reciprocal of the result. For example, 2^(-3) is the same as 1 / (2^3).

To solve this problem efficiently, we'll use the exponentiation by squaring method. This approach reduces the number of multiplications needed.

Here's how it works:

  1. If the exponent is 0, we return 1.

  2. We split the problem in half by calculating x^(n/2).

  3. For even powers, we square the result of the half calculation.

  4. For odd powers, we square the result of the half calculation and multiply by the base once more.

This algorithm has a time complexity of O(log n), where n is the absolute value of the exponent.

PRESENTED BY ACI LEARNING

Get Ready for Your Next Certification—Exclusive discount for you

Are you ready for another certification? Needing to refresh some skills? Planning your next career move? No matter what your training goals are, we’ve got you covered.

  • Over 7,250 hours of IT and Cybersecurity training

  • Flexibility of on-demand training when you want it

  • Engaging video course format that is fun to watch

  • Prep for the most popular certifications

Plus, you will receive 30% off your first month/year with code MASTER30* at checkout - exclusively for Interview Masters!

*offer valid on personal plans only through August 15th 11:59 p.m. ET

SYSTEM DESIGN EXPLAINED

What’s the difference between Forward Proxy and Reverse Proxy?

Source: KNNX Corp.

Forward Proxy acts as an intermediary between clients and external servers. It's typically deployed on the client side and handles outbound traffic. Key components include:

  1. Client-Side Proxy: Intercepts outbound requests from clients.

  2. Anonymity Service: Masks client IP addresses for privacy dependency.

  3. Content Filter: Restricts access to certain websites or content.

  4. Caching System: Stores frequently accessed content to improve performance.

Forward Proxy uses techniques like IP masking to enhance privacy and content filtering to enforce access controls. It's ideal for organizations wanting to manage outbound traffic and maintain user anonymity.

Reverse Proxy, on the other hand, operates on the server side as a front-end for backend servers. Main components include:

  1. Server-Side Proxy: Intercepts incoming client requests.

  2. Load Balancer: Distributes traffic across multiple backend servers.

  3. SSL Termination: Handles encryption/decryption to offload backend servers.

  4. Content Optimizer: Caches static content and compresses data.

Reverse Proxy employs algorithms like round-robin or least connections for load balancing. It also uses caching and compression techniques to optimize content delivery and reduce latency.

The key difference is their placement and purpose: Forward Proxy shields clients from external networks, while Reverse Proxy protects and optimizes backend servers.

NEWS

This week in the tech world

Credit: Anadolu/Contributor via Getty Images

CrowdStrike Update Causes Global IT Outage: A faulty software update from cybersecurity firm CrowdStrike led to widespread IT outages affecting banks, airlines, and other industries worldwide. The issue caused Windows systems to crash, displaying the "blue screen of death." IT experts suggest decentralizing security and implementing redundancies and incremental rollouts to prevent similar global outages.

Google Keeps Third-Party Cookies: Google reversed its plan to phase out third-party cookies for Chrome. Instead, it will introduce a new experience allowing users to make informed choices about their web browsing, citing feedback from advertisers and regulators.

Meta Debuts Llama 3.1 AI Model: Meta announced Llama 3.1, its latest AI model, in partnership with Nvidia and cloud providers. The largest version, trained on 16,000 Nvidia H100 GPUs, is Meta's most capable AI model to date.

OpenAI Launches GPT-4o Mini: OpenAI introduced GPT-4o mini, a smaller version of its most powerful AI model. The company plans to integrate image, video, and audio capabilities later. The new model aims to be cost-efficient and expand ChatGPT's multimodal capabilities.

Tesla Stock Plummets 12%: Tesla shares dropped 12% after disappointing Q2 earnings. Auto revenue fell 7% to $19.9 billion, with margins also declining. The company faces increased competition and has been cutting prices globally.

Amazon Prime Day Sales Soar: U.S. online spending hit a record $14.2 billion during Amazon's Prime Day, up 11% from last year. Consumer electronics and back-to-school items were top sellers. Amazon reported "record-breaking" sales but didn't disclose specific figures.

Wiz Declines $23B Google Deal: Cloud security startup Wiz walked away from a $23 billion acquisition offer from Google. CEO Assaf Rappaport told employees the company will pursue an IPO as originally planned, citing antitrust and investor concerns.

BONUS

Just for laughs 😏

REFER FOR THE WIN

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

📌 Share your referral link on LinkedIn or with your friends to unlock the treasures quicker!
📌 Check your referrals status here.

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.

Until next time, take care! 🚀

Cheers,