• InstaByte
  • Posts
  • OpenAI killed half the AI startups

OpenAI killed half the AI startups

ALSO: Multi-leader Conflicts

Welcome back!

How you approach a simple problem can be more revealing than how you solve a hard one. This week's challenge is exactly that kind of problem.

Today we will cover:

  • Remove Element

  • Multi-leader Conflicts

Read time: under 4 minutes

CODING CHALLENGE

Remove Element

Given an integer array nums and an integer val, remove all occurrences of val in nums in-place. The order of the elements may be changed. Then return the number of elements in nums which are not equal to val.

Consider the number of elements in nums which are not equal to val be k, to get accepted, you need to do the following things:

  • Change the array nums such that the first k elements of nums contain the elements which are not equal to val. The remaining elements of nums are not important as well as the size of nums.

  • Return k.

Custom Judge:

The judge will test your solution with the following code:

int[] nums = [...]; // Input array
int val = ...; // Value to remove
int[] expectedNums = [...]; // The expected answer with correct length. It is sorted with no values equaling val.

int k = removeElement(nums, val); // Calls your implementation

assert k == expectedNums.length;
sort(nums, 0, k); // Sort the first k elements of nums
for (int i = 0; i < k; i++) {
    assert nums[i] == expectedNums[i];
}

If all assertions pass, then your solution will be accepted.

Example 1:

Input: nums = [3,2,2,3], val = 3
Output: 2, nums = [2,2,_,_]
Explanation: Your function should return k = 2, with the first two elements of nums being 2.
It does not matter what you leave beyond the returned k (hence they are underscores).

Example 2:

Input: nums = [0,1,2,2,3,0,4,2], val = 2
Output: 5, nums = [0,1,4,0,3,_,_,_]
Explanation: Your function should return k = 5, with the first five elements of nums containing 0, 0, 1, 3, and 4.
Note that the five elements can be returned in any order.
It does not matter what you leave beyond the returned k (hence they are underscores).

Solve the problem here before reading the solution.

PRESENTED BY THE CODE

Find out why 100K+ engineers read The Code twice a week.

That engineer who always knows what's next? This is their secret.

Here's how you can get ahead too:

  • Sign up for The Code - tech newsletter read by 100K+ engineers

  • Get latest tech news, top research papers & resources

  • Become 10X more valuable

SOLUTION

To solve this problem, we'll use a two-pointer approach. The key idea is to iterate through the array and move all elements that are not equal to the given value to the front of the array.

The algorithm works as follows:

  1. Initialize a pointer k to 0. This will track where to place elements not equal to val.

  2. Iterate through the array with index i.

  3. If the current element at i is not equal to val, copy it to the k-th position and increment k.

  4. By the end of the iteration, the first k elements will contain all elements not equal to val.

  5. Return k, which represents the number of elements not equal to val.

Time complexity of this solution is O(n), where n is the length of the input array.

SYSTEM DESIGN

Multi-leader Conflicts

When multiple database servers can accept writes simultaneously (multi-leader replication), conflicts are bound to happen. Imagine two users trying to update the same customer's phone number at the same time through different database leaders. This creates a conflict that needs to be resolved.

Let's look at different ways to handle these conflicts:

Last Write Wins (LWW) is the simplest approach. Each write gets a timestamp, and the most recent write wins. While easy to implement, this can lead to data loss since a slightly later write might overwrite a more important update.

Custom Conflict Resolution provides more control. You can write rules based on your application's needs. For example, when merging shopping carts from different leaders, you might combine all items rather than picking one version. Or for a document editing system, you might merge changes from different versions if they don't overlap.

Conflict-free Replicated Data Types (CRDTs) are special data structures designed to be merged automatically without conflicts. For example, a counter that can only be incremented will always reach the correct final value regardless of the order of updates. However, CRDTs are limited to specific use cases and can't handle all types of data.

FEATURED COURSES

5 Courses of the Week

 Amazon Developer Certificate: Learn software development fundamentals with Java programming, data structures, and full-stack web development through real-world projects and a capstone challenge.

 Amazon’s Data Structures & Algorithms: Implement and analyze fundamental data structures and algorithms in Java, including sorting, searching, and recursive techniques with JUnit testing methodology.

 Meta Front-End Developer Certificate: Master web development skills by learning HTML5, CSS, JavaScript, and industry-standard design tools like Bootstrap and React. You'll complete multiple projects and a final capstone project.

 AI Programming with Python: Build Python fundamentals for AI using NumPy, Pandas, and Matplotlib. Learn deep learning frameworks like PyTorch and natural language processing with Transformers.

 IBM GenAI Engineering Certificate: Master LLMs, transformers, and NLP. Build AI apps using BERT, GPT, LLaMA. Includes hands-on projects using LangChain and RAG.

WHAT'S NEW IN AI? 

The Gold standard for AI news

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

OpenAI Unveils AgentKit at Dev Day: OpenAI launched AgentKit, a toolkit for building AI agents, alongside apps inside ChatGPT. The platform includes Agent Builder for visual workflows, ChatKit for embeddable interfaces, and Evals for Agents.

OpenAI Sora 2 Hits #1 on App Store: OpenAI launched Sora 2, its AI video generator with synchronized audio, alongside a TikTok-style social app. Despite being invite-only, the app topped Apple's App Store with 164,000 downloads in two days, outpacing Gemini and ChatGPT.

Anthropic Opens First India Office: Anthropic will open its first India office in Bengaluru in early 2026, its second in Asia after Tokyo. CEO Dario Amodei is visiting India this week to meet officials and partners. India ranks second in Claude usage globally, with over 90% of workers already using AI.

Red Hat GitLab Breach Exposes 800+ Organizations: Hackers breached Red Hat's consulting GitLab instance, stealing 570GB of data from 28,000 repositories. The Crimson Collective claims to have accessed Customer Engagement Reports containing credentials and infrastructure details from Bank of America, JPMorgan, Verizon, and government agencies.

Nvidia CEO Criticizes H-1B Visa Changes: Nvidia CEO Jensen Huang said his family couldn't have afforded to immigrate under Trump's new H-1B policy requiring a $100,000 fee per visa. Nvidia sponsors 1,400 visas and will continue covering the fees for employees.

Google Restricts Work From Anywhere Policy: Google tightened its "Work From Anywhere" benefit, requiring full-week increments. A single remote day now counts as an entire week, reducing flexibility from the 4-week annual allowance.

Quantum Computing Stocks Skyrocket: Quantum computing stocks surged this week, with IonQ jumping 135% and Rigetti 105% over six months. IonQ achieved #AQ 64 performance milestone, doubling its quantum computing space.

Vercel Raises $300M at $9.3B Valuation: The developer platform secured a Series F round co-led by Accel and GIC, with participation from BlackRock and StepStone. Vercel powers deployment for OpenAI, Anthropic, and Nike, positioning itself as critical infrastructure for AI-powered applications.

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,