• InstaByte
  • Posts
  • Google & Meta's favorite problem

Google & Meta's favorite problem

ALSO: What is Load Shedding?

In partnership with

Welcome back!

This week’s problem might be easy, but it was asked by 4 out of 5 FAANGs. Read along to know which ones 😉 

Today we will cover:

  • Valid Anagram

  • What is Load Shedding?

Read time: under 4 minutes

CODING CHALLENGE

Valid Anagram

Given two strings s and t, return true if t is an anagram of s, and false otherwise.

Example 1:

Input: s = "anagram", t = "nagaram"
Output: true

Example 2:

Input: s = "rat", t = "car"
Output: false

Solve the problem here before reading the solution.

PRESENTED BY MAVEN AGI

Drowning In Support Tickets? Maven AGI is here to help.

Maven AGI platform simplifies customer service by unifying systems, improving with every interaction, and automating up to 93% of responses. Seamlessly integrated with 50+ tools like Salesforce, Freshdesk, and Zendesk, Maven can deploy AI agents across multiple channels—text, email, web, voice, and apps—within days. Companies like Tripadvisor, ClickUp, and Rho slash response times by 60%, ensuring quicker support and exceptional customer satisfaction. Don’t let support tickets slow you down

SOLUTION

To solve this problem, we'll use a HashMap to count the frequency of characters in both strings. If two strings are anagrams, they should have the same characters with the same frequencies.

First, we'll check if the lengths of both strings are equal. If not, they can't be anagrams. Then, we'll create a dictionary to store character frequencies.

For each character in the first string, we'll increment its count, and for each character in the second string, we'll decrement its count. If all counts in our dictionary are zero at the end, the strings are anagrams.

The time complexity of this solution is O(n), where n is the length of the input strings.

SYSTEM DESIGN

What is Load Shedding?

When your service suddenly gets hit with millions of requests during a viral marketing campaign, users might face slow responses or worse, the entire system could crash. Load shedding solves this by intelligently dropping some requests to keep the system running smoothly.

Load shedding is different from basic rate limiting. While rate limiting puts a cap on how many requests a client can make, load shedding makes dynamic decisions about which requests to process based on the system's current health and request priorities.

Think of an e-commerce platform during Black Friday. When the system gets overwhelmed, instead of treating all requests equally, it might prioritize "complete purchase" requests over "view product details" requests. This ensures that customers who are ready to buy can complete their transactions, even if some browsing functionality is temporarily limited.

There are several strategies for implementing load shedding:

Random shedding drops requests randomly with a probability that increases as system load increases. While simple, this approach can be effective when all requests have similar importance.

Latency-based shedding drops requests when response times exceed certain thresholds. This helps prevent cascading failures where slow responses lead to resource exhaustion.

Priority-based shedding drops low-priority requests first. For example, letting premium users continue using all features while restricting some features for free users.

Token bucket shedding assigns tokens to different types of requests. When the system is under stress, requests requiring more tokens are more likely to be dropped. This works well for protecting resource-intensive operations.

Load shedding needs careful monitoring and adjustment. Drop too many requests, and you're unnecessarily turning away users. Drop too few, and you risk system failure. Modern systems often use machine learning to optimize these decisions based on historical patterns.

FEATURED COURSES

5 Courses of the Week

 Building LLM Applications With Prompt Engineering: Foundation course for advanced techniques like RAG and PEFT for prompt engineering, using NVIDIA NIM (Llama-3.1) and LangChain.

 Getting Started with Deep Learning: Get a practical introduction to deep learning through computer vision and NLP exercises, learn about model training, data augmentation and transfer learning.

 An Even Easier Introduction to CUDA: Learn hands-on CUDA programming for NVIDIA GPUs and master massively parallel GPU computations.

 Microsoft Azure for AI and ML: Your first course after learning Python, cover the full ML lifecycle from data prep to production deployment using Azure’s AI/ML services and workflows.

 Google Cloud Big Data and ML Fundamentals: Explore Big data pipeline construction in Google’s Vertex AI platform.

 Last Chance to get your 10% discount on any NVIDIA courses or NVIDIA certifications with code “POWERCOUPLE” at checkout.

HEARD OF 1440? 

Seeking impartial news? Meet 1440.

Every day, 3.5 million readers turn to 1440 for their factual news. We sift through 100+ sources to bring you a complete summary of politics, global events, business, and culture, all in a brief 5-minute email. Enjoy an impartial news experience.

NEWS

This Week in the Tech World

TikTok Service Restored: TikTok resumed US operations after Trump promised to delay the federal ban. The app was briefly removed from app stores but returned after Trump announced plans for an executive order on Monday to extend the deadline for ByteDance's divestment.

DeepSeek Launches New AI Model: Chinese AI lab DeepSeek unveiled DeepSeek-R1, a reasoning model matching OpenAI's performance in math and coding while being 90% cheaper. The open-source model excels at problem-solving and achieved 93% accuracy in math benchmarks, challenging major AI competitors.

Tech CEOs at Trump Inauguration: Top tech leaders including Zuckerberg, Bezos, Pichai, and Musk secured prime seats at Trump's inauguration ceremony. Breaking tradition, the front-row spots usually reserved for family members went to tech executives, with Apple's Cook and TikTok's Chew also attending.

Stripe Cuts Jobs Despite Growth: Stripe lays off 300 employees (3.5% of workforce) in product, engineering and operations, while still planning to grow headcount by 17% this year. Company maintains $70B valuation and hit $1T in payment volume in 2023.

Perplexity AI Bids for TikTok: AI search startup Perplexity AI made a bid to merge with TikTok US. The proposed deal would combine both companies and new capital partners, allowing ByteDance's investors to keep their stakes. The deal values TikTok US at over $50 billion.

Google Maps Turns 20: Google Maps celebrates its 20th anniversary by expanding to three new countries and adding AI features. The service launched new portable Street View cameras and integrated Gemini AI for enhanced navigation and real-time disruption reporting.

Apple Struggles in China: Apple's stock dropped 4% after reports showed iPhone sales fell to third place in China behind Vivo and Huawei. The company's market share dropped 17% in 2024, while key supplier TSMC reported declining smartphone chip demand.

WHAT'S NEW IN AI?

Learn how to make AI work for you

AI won’t take your job, but a person using AI might. That’s why 1,000,000+ professionals read The Rundown AI – the free newsletter that keeps you updated on the latest AI news and teaches you how to use it in just 5 minutes a day.

BONUS

Just for laughs 😏

HELP US

👋 Hi there! We are on a mission to provide as much value as possible for free. If you want this newsletter to remain free, please help us grow by referring your friends:

📌 Share your referral link on LinkedIn or directly with your friends.
📌 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,