- InstaByte
- Posts
- DeepSeek did it again!
DeepSeek did it again!
ALSO: Optimistic vs Pessimistic Locking
Welcome back!
This week, we will solve the most popular number puzzle on the planet. Back in the day, many people would buy a newspaper just to solve this puzzle. Are you ready?
Today we will cover:
Valid Sudoku
Optimistic vs Pessimistic Locking
Read time: under 4 minutes
CODING CHALLENGE
Valid Sudoku
Determine if a 9 x 9
Sudoku board is valid. Only the filled cells need to be validated according to the following rules:
Each row must contain the digits
1-9
without repetition.Each column must contain the digits
1-9
without repetition.Each of the nine
3 x 3
sub-boxes of the grid must contain the digits1-9
without repetition.
Note:
A Sudoku board (partially filled) could be valid but is not necessarily solvable.
Only the filled cells need to be validated according to the mentioned rules.
Example 1:

Input: board =
[["5","3",".",".","7",".",".",".","."]
,["6",".",".","1","9","5",".",".","."]
,[".","9","8",".",".",".",".","6","."]
,["8",".",".",".","6",".",".",".","3"]
,["4",".",".","8",".","3",".",".","1"]
,["7",".",".",".","2",".",".",".","6"]
,[".","6",".",".",".",".","2","8","."]
,[".",".",".","4","1","9",".",".","5"]
,[".",".",".",".","8",".",".","7","9"]]
Output: true
Example 2:
Input: board =
[["8","3",".",".","7",".",".",".","."]
,["6",".",".","1","9","5",".",".","."]
,[".","9","8",".",".",".",".","6","."]
,["8",".",".",".","6",".",".",".","3"]
,["4",".",".","8",".","3",".",".","1"]
,["7",".",".",".","2",".",".",".","6"]
,[".","6",".",".",".",".","2","8","."]
,[".",".",".","4","1","9",".",".","5"]
,[".",".",".",".","8",".",".","7","9"]]
Output: false
Explanation: Same as Example 1, except with the 5 in the top left corner being modified to 8. Since there are two 8's in the top left 3x3 sub-box, it is invalid.
Solve the problem here before reading the solution.
PRESENTED BY SUPERHUMAN AI
Start learning AI in 2025

In 2 years you will be working for AI or an AI will be working for you.
That's why 1M+ pros working at Google, Meta & OpenAI read Superhuman AI. Join now & learn AI skills, the latest AI tools & news in just 3 minutes a day.
SOLUTION
To solve this problem, we'll validate the Sudoku board by checking three conditions:
No repetition in rows
No repetition in columns
No repetition in
3x3
sub-boxes
We'll use sets to efficiently track unique digits in each row, column, and sub-box. By checking each condition during a pass through the board, we can determine its validity.
Time complexity is O(1)
since the board size is fixed at 9x9
. Space complexity is also O(1)
as we're using a constant amount of extra space.

SYSTEM DESIGN
Optimistic vs Pessimistic Locking

When multiple users try to update the same data in a database simultaneously, it can lead to data inconsistency. For example, if two bank tellers try to update a customer's balance at the same time, one update might override the other. Database locking helps prevent such conflicts.
There are two main approaches to handle concurrent updates: Optimistic Locking and Pessimistic Locking.
Optimistic Locking assumes conflicts are rare. It lets users make changes freely but checks for conflicts before saving. Each record has a version number that increases with each update. When saving changes, the system verifies if the last version number matches what it was when the user started editing. If someone else made changes in between, the version numbers won't match, and the save fails.
This approach works well for systems where conflicts are uncommon, like social media posts where users typically edit their own content. It's also more efficient since it doesn't block other users from reading or editing.
Pessimistic Locking takes a more cautious approach. When a user starts editing a record, it gets locked immediately. Other users must wait until the first user finishes.
This approach is better for systems where conflicts are likely and data consistency is crucial, like banking transactions. But it can create performance issues if locks are held for too long, as other users are forced to wait.
Here's how they compare:
Features | Optimistic Locking | Pessimistic Locking |
---|---|---|
Performance | Better | Worse |
Concurrency | Higher | Lower |
Conflict Handling | Detects at save time | Prevents conflicts |
Best For | Low-conflict scenarios | High-conflict scenarios |
Example Use Case | Social media posts | Financial transactions |
FEATURED COURSES
5 Courses of the Week
✅ 100 Days of Code: Master the Python programming language by building 100 unique projects over 100 days.
✅ Docker & Kubernetes Guide: Complete guide to containerization - from Docker basics to complex Kubernetes deployments. Covers installation, networking, and practical implementation.
✅ DevOps Beginners to Advanced: 10-step journey from Linux basics to advanced DevOps, covering AWS, Jenkins, Docker, Kubernetes, and Terraform with hands-on projects.
✅ Android Kotlin Developer: Learn the latest in development technology using Android Studio.
✅ DeepLearning.AI Data Engineering Certificate: Build data pipelines on AWS, design data architectures, and learn batch/streaming processing. Hands-on labs with real-world tools.
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

DeepSeek Upgrades AI Model: Chinese startup DeepSeek quietly released an upgraded R1 reasoning model that's now competing with OpenAI's top models, despite U.S. tech restrictions on China.
Neuralink Raises $650M: Elon Musk's brain-chip startup Neuralink raised $650 million from top investors including ARK Invest and Sequoia Capital. Five patients now control devices with their thoughts using the Telepathy system.
Snowflake Buys Crunchy Data: Cloud analytics giant Snowflake acquired database startup Crunchy Data for $250 million. The deal helps Snowflake compete with rival Databricks in the AI agent market.
Meta AI Hits 1 Billion Users: Meta's AI assistant reached one billion monthly users across its apps. CEO Zuckerberg plans to add paid features and subscriptions as the service grows.
Russia Plans AI in Space: Russia will integrate its homegrown Gigachat AI model into the International Space Station this autumn to help process satellite imagery and assist cosmonauts.
Nvidia Reclaims Top Spot: Nvidia surpassed Microsoft to become the world's most valuable company again with a $3.45 trillion market cap. The AI chipmaker's stock surged 24% in a month despite trade concerns.
Musk Exits Government Role: Elon Musk thanked Trump and announced he's leaving his DOGE government efficiency role after 130 days. Tesla investors now demand he work 40 hours per week at the EV company.
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,