- InstaByte
- Posts
- AI war heats up: Meta vs OpenAI
AI war heats up: Meta vs OpenAI
ALSO: Database Leader Election

Welcome back!
This week we’ll crack an Easy problem. Even though it’s easy, it’s asked by almost all of the FAANGs. Let’s find out why.
Today we will cover:
Merge Sorted Array
Database Leader Election
Read time: under 4 minutes
CODING CHALLENGE
Merge Sorted Array
You are given two integer arrays nums1
and nums2
, sorted in non-decreasing order, and two integers m
and n
, representing the number of elements in nums1
and nums2
respectively.
Merge nums1
and nums2
into a single array sorted in non-decreasing order.
The final sorted array should not be returned by the function, but instead be stored inside the array nums1
. To accommodate this, nums1
has a length of m + n
, where the first m
elements denote the elements that should be merged, and the last n
elements are set to 0
and should be ignored. nums2
has a length of n
.
Example 1:
Input: nums1 = [1,2,3,0,0,0], m = 3, nums2 = [2,5,6], n = 3
Output: [1,2,2,3,5,6]
Explanation: The arrays we are merging are [1,2,3] and [2,5,6].
The result of the merge is [1,2,2,3,5,6] with the underlined elements coming from nums1.
Example 2:
Input: nums1 = [1], m = 1, nums2 = [], n = 0
Output: [1]
Explanation: The arrays we are merging are [1] and [].
The result of the merge is [1].
Solve the problem here before reading the solution.
MASTER AI
Want to get the most out of ChatGPT?
ChatGPT is a superpower if you know how to use it correctly.
Discover how HubSpot's guide to AI can elevate both your productivity and creativity to get more things done.
Learn to automate tasks, enhance decision-making, and foster innovation with the power of AI.
SOLUTION
To solve this problem efficiently, we'll use a two-pointer approach starting from the end of the arrays. This allows us to merge the arrays in-place without using extra space.
We'll compare elements from the end of both arrays and place them at the end of nums1
. This approach works because nums1
has enough space to accommodate all elements.
We'll start with three pointers:
One at the last actual element in
nums1
(m-1)
One at the last actual element in
nums2
(n-1)
One at the last position of
nums1
(m+n-1)
We'll compare elements and place the larger one at the end of nums1
, moving the pointers accordingly.
Time complexity is O(m+n)
as we traverse both arrays once.

HEARD OF SUPERHUMAN?
Start learning AI in 2025
Keeping up with AI is hard – we get it!
That’s why over 1M professionals read Superhuman AI to stay ahead.
Get daily AI news, tools, and tutorials
Learn new AI skills you can use at work in 3 mins a day
Become 10X more productive
SYSTEM DESIGN
Database Leader Election

When you have multiple servers working together in a distributed system, you often need one server to be in charge, to be the leader. But what happens when the leader fails? You need a way to choose a new leader automatically. This is where leader election mechanisms come in.
The most popular leader election mechanism is the ZooKeeper Atomic Broadcast (ZAB) protocol, used in Apache ZooKeeper. Here's how it works: When servers notice the leader is down, they start an election. Each server proposes itself as leader with a vote number. The server with the highest vote number (usually based on transaction ID) wins the election.
Another common approach is the Raft consensus algorithm. In Raft, each server starts as a follower. If followers don't hear from a leader, they become candidates and request votes from other servers. The first candidate to get votes from the majority becomes the leader. If multiple candidates split the vote, a new election round starts.
Both these mechanisms ensure that:
Only one leader is elected at a time
All servers agree on who the leader is
A new leader can be elected if the current one fails
But leader election has some challenges. Network issues might make servers think the leader is down when it's actually fine, triggering unnecessary elections. This is called the "split-brain" problem. To prevent this, systems usually require a majority vote (quorum) before electing a new leader.
FEATURED COURSES
5 Courses of the Week
✅ Advanced AI Agents & Multi-Agent Systems Masterclass: Comprehensive program covering sophisticated AI agent engineering from advanced prompting techniques (Chain-of-Thought, ReAct) to building coordinated multi-agent systems with Python.
✅ Complete Web Development & JavaScript Mastery Bundle: Comprehensive full-stack development program including 62+ hour web development bootcamp (HTML, CSS, JavaScript, React, Node.js, databases, Web3), JavaScript interview preparation with 100+ videos for interview mastery.
✅ 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. It covers everything from basics to professional development with Flask, APIs, databases, and deployment.
✅ 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.
✅ Deep Learning Nanodegree Program: Comprehensive deep learning program covering fundamental neural networks through advanced architectures including CNNs for image processing, RNNs for sequential data, GANs for generation, and transformer models.
NEWS
This Week in the Tech World

Meta's AI Spending Spree Continues: Meta invested $14.3 billion in Scale AI and hired top talent including ChatGPT co-creator Shengjia Zhao after its Llama 4 AI model disappointed developers. The company is overhauling its AI strategy to compete with OpenAI.
Alibaba Launches AI-Powered Smart Glasses: Alibaba unveiled Quark AI Glasses powered by its AI models, launching in China by end-2025. The glasses compete with Meta's Ray-Ban collaboration and offer translation, navigation, and Alipay payments.
Tesla Signs $16.5 Billion Chip Deal with Samsung: Elon Musk confirmed Tesla's massive semiconductor contract with Samsung Electronics through 2033. Samsung's Texas fab will make Tesla's next-generation AI6 chip, with Musk calling the strategic importance hard to overstate.
India Overtakes China in US Smartphone Exports: India became the top smartphone exporter to the US with 44% market share, up from 13% last year. Apple's manufacturing shift drove the 240% jump as Chinese exports dropped to 25% amid trade tensions.
Palo Alto Networks Buys CyberArk for $25 Billion: Palo Alto Networks will acquire Israeli identity security provider CyberArk for $25 billion, paying a 26% premium. The deal helps Palo Alto enter the identity market as cybersecurity consolidation accelerates.
Foxconn Joins $1 Trillion AI Data Center Market: iPhone maker Foxconn took a 10% stake in TECO Electric to become a one-stop shop for AI data centers. The partnership targets the potential $1 trillion spending on data centers by tech companies.
LG Energy Solution Signs $4.3 Billion Battery Deal: South Korea's LG Energy Solution signed a $4.3 billion battery supply contract through 2030, reportedly with Tesla. The deal eclipses the company's quarterly revenue and signals growing US energy storage demand.
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! |
Until next time, take care! 🚀
Cheers,