- InstaByte
- Posts
- Chinese AI Model beats ChatGPT
Chinese AI Model beats ChatGPT
ALSO: Database Sharding Strategies

Welcome back!
This week's problem will twist your brain in knots. But once you understand it, the solution is surprisingly simple. All the best!
Today we will cover:
Copy List with Random Pointer
Database Sharding Strategies
Read time: under 4 minutes
CODING CHALLENGE
Copy List with Random Pointer
A linked list of length n
is given such that each node contains an additional random pointer, which could point to any node in the list, or null
.
Construct a deep copy of the list. The deep copy should consist of exactly n
brand new nodes, where each new node has its value set to the value of its corresponding original node. Both the next
and random
pointer of the new nodes should point to new nodes in the copied list such that the pointers in the original list and copied list represent the same list state. None of the pointers in the new list should point to nodes in the original list.
For example, if there are two nodes X
and Y
in the original list, where X.random --> Y
, then for the corresponding two nodes x
and y
in the copied list, x.random --> y
.
Return the head of the copied linked list.
The linked list is represented in the input/output as a list of n
nodes. Each node is represented as a pair of [val, random_index]
where:
val
: an integer representing Node.val
random_index
: the index of the node (range from 0
to n-1
) that the random
pointer points to, or null
if it does not point to any node.
Your code will only be given the head
of the original linked list.
Example 1:

Input: head = [[7,null],[13,0],[11,4],[10,2],[1,0]]
Output: [[7,null],[13,0],[11,4],[10,2],[1,0]]
Example 2:

Input: head = [[1,1],[2,1]]
Output: [[1,1],[2,1]]
Solve the problem here before reading the solution.
PRESENTED BY THE RUNDOWN AI
Start learning AI in 2025
Everyone talks about AI, but no one has the time to learn it. So, we found the easiest way to learn AI in as little time as possible: The Rundown AI.
It's a free AI newsletter that keeps you up-to-date on the latest AI news, and teaches you how to apply it in just 5 minutes a day.
Plus, complete the quiz after signing up and they’ll recommend the best AI tools, guides, and courses – tailored to your needs.
SOLUTION
To solve this problem, we'll use a hash map to create a deep copy of the linked list while maintaining the original list's structure. The hash map will help us map original nodes to their corresponding new nodes.
We'll do this in two passes:
First, create new nodes and map original nodes to their copies.
Then, set the next and random pointers for the new nodes.
This approach ensures that we create a completely independent copy of the original linked list, with new nodes that have the same values and pointer relationships.
The time complexity is O(n)
, where n
is the number of nodes in the linked list. We make two passes through the list.
The space complexity is also O(n)
due to the hash map storing node mappings.

SYSTEM DESIGN
Database Sharding Strategies

As your application grows, a single database server might struggle to handle all the data and user requests. Database sharding solves this by splitting your data across multiple servers, but choosing the right sharding strategy is crucial for performance.
Range-based Sharding divides data based on ranges of a specific field. For example, if you're storing user data, you might put users with IDs 1-1000000 on one server, 1000001-2000000 on another, and so on. This strategy works well when you need to retrieve data within specific ranges, like finding all orders from the last month. However, if the chosen ranges aren't balanced, some servers might end up with more traffic than others.
Hash-based Sharding uses a hash function to determine which server stores each piece of data. When storing user data, you might hash the user ID and use the result to pick a server. Hash-based sharding typically distributes data more evenly than range-based sharding, but it makes range queries harder since related data might be spread across different servers.
Geographic Sharding stores data on servers physically closest to where it's most frequently accessed. For a social media platform, European users' data might be stored on servers in Europe, while Asian users' data stays on Asian servers. This reduces latency but can complicate data access when users interact across regions.
Here's a comparison of these strategies:
Strategy | Data Distribution | Range Queries | Geographic Performance |
---|---|---|---|
Range-based | Can be uneven | Efficient | Not optimized |
Hash-based | Even | Inefficient | Not optimized |
Geographic | Based on location | Moderate | Highly efficient |
The choice of sharding strategy depends on your specific needs. Range-based sharding works well for time-series data, hash-based sharding is great for evenly distributed workloads, and geographic sharding shines in global applications where latency matters.
FEATURED COURSES
5 Courses of the Week
✅ 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, covering everything from basics to professional development with Flask, APIs, databases, and deployment.
✅ React - The Complete Guide: Comprehensive 40+ hour React course covering fundamentals through advanced concepts including hooks, routing, Redux, Next.js, TypeScript, authentication, and testing, with hands-on projects and updated for React 19 features.
✅ Java Masterclass: Beginner-friendly Java course taught by Oracle-certified experts, covering fundamentals through advanced topics with hands-on coding notebooks and practical examples to prepare students for Java programming jobs and freelance opportunities.
✅ Python Programming for AI: Build Python fundamentals for AI using NumPy, pandas, and Matplotlib, then progress to machine learning models, PyTorch neural networks, deep learning frameworks, and generative AI with Transformers for natural language processing applications.
✅ Reinforcement Learning Course: Learn AI foundations behind ChatGPT and GPT-4, covering multi-armed bandits, Markov Decision Processes, Q-Learning, and approximation methods with hands-on implementation from scratch including a stock trading bot project.
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
NEWS
This Week in the Tech World

Moonshot's Kimi K2 Beats ChatGPT: Chinese AI startup Moonshot released open-source Kimi K2 model that outperforms ChatGPT and Claude in coding tasks. The model costs 100 times less than Claude Opus 4 and is available for free, threatening US AI dominance.
Google Hires Windsurf CEO for $2.4B: Google acquired Windsurf's CEO and senior staff in a $2.4 billion talent deal after OpenAI's $3 billion acquisition talks failed. The move intensifies the AI coding talent war between tech giants.
Cognition Buys Windsurf After Google Poaches CEO: AI startup Cognition acquired Windsurf days after Google hired its CEO and team for $2.4 billion. The acquisition follows a failed $3 billion OpenAI deal, highlighting the fierce AI talent war between tech giants.
Pentagon Awards $200M AI Contracts: The Defense Department granted up to $200 million in AI contracts to Anthropic, Google, OpenAI, and xAI. The awards aim to accelerate military AI adoption for national security, with Musk's xAI launching Grok for Government.
Zuckerberg Plans AI Supercluster Investment: Meta CEO announced plans to invest "hundreds of billions" in AI compute infrastructure. The company's first supercluster "Prometheus" will launch in 2026, with another cluster scaling to five gigawatts.
Nvidia's Huang Sells $36M in Stock: Nvidia CEO Jensen Huang sold $36.4 million worth of shares as part of a planned stock sale. His net worth reached $143 billion, nearly matching Warren Buffett, as Nvidia became the first $4 trillion company.
Intel Spins Out RealSense Robotics: Intel spun out its AI robotics unit RealSense with $50 million funding. The move comes as companies bet big on automation, with Morgan Stanley predicting a $5 trillion humanoid robot market by 2050.
Grok 4 Seeks Musk's Views on Controversial Topics: Elon Musk's new Grok 4 chatbot appears to search for Musk's opinions when answering contentious questions. The $30/month AI referenced Musk's stance on political issues, raising bias concerns.
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,