Half the internet just died

ALSO: CAP Theorem in Practice

Welcome back!

Let me be real with you: when I saw today’s coding challenge for the first time, I was completely lost. Let's see if you can crack it.

Today we will cover:

  • Bitwise AND of Numbers Range

  • CAP Theorem in Practice

Read time: under 4 minutes

CODING CHALLENGE

Bitwise AND of Numbers Range

Given two integers left and right that represent the range [left, right], return the bitwise AND of all numbers in this range, inclusive.

Example 1:

Input: left = 5, right = 7
Output: 4

Example 2:

Input: left = 0, right = 0
Output: 0

Example 3:

Input: left = 1, right = 2147483647
Output: 0

Solve the problem here before reading the solution.

PRESENTED BY HUBSPOT

Build your next app on HubSpot!

The HubSpot Developer Platform gives you the tools to build, extend, and scale with confidence. Create AI-ready apps, integrations, and workflows faster with a unified platform designed to grow alongside your business.

SOLUTION

When you AND all numbers in a range together, only the bits that stay constant across every number survive. Everything else becomes zero.

Within the range [left , right], the least significant bits will change. But the most significant bits (the prefix) remain the same across the range. So you just need to find the longest common binary prefix of left and right.

Here is how to solve the problem:

  1. Continuously right-shift both left and right numbers until they become equal. This will give you the longest common prefix.

  2. Keep track of the number of shifts

  3. Left-shift the prefix by the number of shifts to get the answer

For example:

  • left = 5 (101 in binary)

  • right = 7 (111 in binary)

Shifting right once gives:

  • 5 becomes 2 (010 in binary)

  • 7 becomes 3 (011 in binary)

Shift right one more time, both become 1.

1 is your prefix which we got by shifting right 2 times. Shift this prefix left 2 times, we get 4 (100 in binary) which is our answer.

SYSTEM DESIGN

CAP Theorem in Practice

When building distributed systems, you'll often hear about the CAP theorem. It states that when data is distributed across multiple servers, you can only have two out of these three properties: Consistency, Availability, and Partition Tolerance. Let's understand what this means in practice.

Consistency means all servers have the same data at any given time. If you write data to one server, all other servers should show this updated data. Availability means the system remains operational even if some servers fail. Partition Tolerance means the system continues to work even when network issues prevent servers from communicating with each other.

In real distributed systems, network partitions will happen. Servers will lose connection with each other due to network issues, hardware failures, or maintenance. This means Partition Tolerance isn't really optional, you must have it. So practically, you're choosing between Consistency and Availability.

If you choose Consistency over Availability (CP system), when a network partition occurs, some parts of your system become unavailable to maintain consistency. For example, if two database servers can't communicate, one might stop accepting writes to prevent inconsistent data.

If you choose Availability over Consistency (AP system), your system keeps working during network partitions, but different servers might show different data temporarily. Once the network issues resolve, the servers sync up their data.

Here's how popular databases handle this trade-off:

Database

CAP Choice

Best For

MongoDB

CP

Financial transactions

Cassandra

AP

Social media feeds

PostgreSQL

CP

Banking applications

DynamoDB

AP

Shopping carts

FEATURED COURSES

5 Courses of the Week

 Intro to Git and GitHub: Understand version control and learn how to collaborate with others using Git and Github.

 100 Days of Code: The Complete Python Pro Bootcamp: Comprehensive 60+ hour Python course building 100 projects including games, web apps, automation tools, and data science projects.

 Stanford’s ML Specialization: Build practical ML models using NumPy, scikit-learn, and TensorFlow across supervised and unsupervised learning techniques. Learn to create real-world AI apps including neural networks, recommendation systems, and reinforcement learning models.

 Automate the Boring Stuff with Python: Practical Python automation course for complete beginners covering web scraping, PDF/Excel parsing, keyboard/mouse automation, email/text sending, and other productivity tasks to streamline tedious work without requiring computer science background.

 Meta Android Developer Certificate: Learn Android programming with Kotlin to build mobile apps like Facebook. Includes portfolio-building projects.

BECOME AI SAVVY

Go from AI overwhelmed to AI savvy professional

AI will eliminate 300 million jobs in the next 5 years.

Yours doesn't have to be one of them.

Here's how to future-proof your career:

  • Join the Superhuman AI newsletter - read by 1M+ professionals

  • Learn AI skills in 3 mins a day

  • Become the AI expert on your team

NEWS

This Week in the Tech World

AWS Outage Breaks the Internet: DNS failure in AWS US-EAST-1 region caused 7-hour outage affecting Snapchat, Roblox, Ring, Reddit, and thousands of sites. DynamoDB issues cascaded across services.

Anthropic Launches Claude Code for Web: Claude Code is now available as a browser-based coding agent for Pro and Max subscribers. Developers can delegate coding tasks without opening a terminal.

AI Bubble Warning Grows: Tech leaders including Sam Altman caution that AI market may be overvalued. Fund managers cite AI bubble as top risk to markets amid inflated expectations.

Meta Cuts 600 AI Unit Jobs: Meta laid off 600 employees within its AI division as part of ongoing restructuring. Company continues efficiency push despite massive AI investments.

AWS Launches GenAI Certification: AWS introduced Certified Generative AI Developer Professional certification. Beta exam opens November 18, validating skills in RAG architectures and vector databases.

Meta Exec Pushes 5X Productivity: Internal Meta memo demands 5X productivity gains in software development using AI. Move reflects aggressive push toward AI-assisted development across Big Tech.

Deel Hits $17.3B Valuation: HR platform Deel raised $300 million Series E, reaching unicorn status. Company crossed $100 million in monthly recurring revenue despite litigation with Rippling.

HEARD OF MINDSTREAM?

Turn AI Into Your Income Stream

The AI economy is booming, and smart entrepreneurs are already profiting. Subscribe to Mindstream and get instant access to 200+ proven strategies to monetize AI tools like ChatGPT, Midjourney, and more. From content creation to automation services, discover actionable ways to build your AI-powered income. No coding required, just practical strategies that work.

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,