- InstaByte
- Posts
- ChatGPT launches ads
ChatGPT launches ads
ALSO: Idempotency in Distributed Systems

Welcome back!
This week’s coding challenge is not as easy as it looks. Even if you know the solution, finding the time complexity is hard. Let’s see if you can solve it.
Today we will cover:
Convert Sorted Array to Binary Search Tree
Idempotency in Distributed Systems
Read time: under 4 minutes
CODING CHALLENGE
Convert Sorted Array to Binary Search Tree
Given an integer array nums where the elements are sorted in ascending order, convert it to a height-balanced binary search tree.
Example 1:

Input: nums = [-10,-3,0,5,9]
Output: [0,-3,9,-10,null,5]
Explanation: [0,-10,5,null,-3,null,9] is also accepted:
Example 2:

Input: nums = [1,3]
Output: [3,1]
Explanation: [1,null,3] and [3,1] are both height-balanced BSTs.Solve the problem here before reading the solution.
PRESENTED BY MORNING BREW
Trusted by millions. Actually enjoyed by them too.
Morning Brew makes business news something you’ll actually look forward to — which is why over 4 million people read it every day.
Sure, the Brew’s take on the news is witty and sharp. But the games? Addictive. You might come for the crosswords and quizzes, but you’ll leave knowing the stories shaping your career and life.
Try Morning Brew’s newsletter for free — and join millions who keep up with the news because they want to, not because they have to.
SOLUTION
To convert a sorted array into a height-balanced BST, we can use a recursive approach. The middle element of the array will be the root of our tree. The left subtree will be constructed from elements before the middle element, and the right subtree from elements after the middle element.
The time complexity of this solution is O(n), where n is the number of elements in the array. That’s because we’re processing each element exactly once.
Many people might think that the time complexity should be O(log(n)) because we are splitting the array in half at each step. But if you notice, we are processing both the left and the right half of the array after splitting. This means that we are not cutting the search space in half at each step. So time complexity is not O(log(n)).

NO FLUFF AI
AI You’ll Actually Understand
Cut through the noise. The AI Report makes AI clear, practical, and useful—without needing a technical background.
Join 400,000+ professionals mastering AI in minutes a day.
Stay informed. Stay ahead.
No fluff—just results.
SYSTEM DESIGN
Idempotency in Distributed Systems

In distributed systems, network failures or timeouts can cause operations to be accidentally repeated. For example, when you click "Submit Payment" and get a network error, you might click again because you don’t know if the first payment went through. This can lead to double payments or other unwanted duplicates. Idempotency solves this problem.
An operation is idempotent if running it multiple times has the same effect as running it once. Here's how we implement idempotency in distributed systems:
1. Idempotency Keys: Each request gets a unique ID. When the server receives a request, it first checks if it has seen this ID before. If yes, it returns the cached response instead of processing the request again.
2. Request De-duplication: The server maintains a record of processed request IDs. This record can be stored in the cache. When a new request arrives, the server checks this record before processing.
3. Natural Idempotency: Some operations are naturally idempotent. Setting a user's name to "John" multiple times has the same effect as doing it once. But incrementing a counter isn't idempotent because each operation changes the result.
Here's a comparison of different types of operations:
Operation Type | Example | Idempotent |
|---|---|---|
Read | Get user profile | Yes |
Create | Create new order | No (needs idempotency key) |
Update | Set user name | Yes |
Delete | Delete account | Yes |
Increment | Add to counter | No |
Implementing idempotency adds complexity but it’s crucial for building reliable distributed systems. It prevents duplicate operations and gives users confidence that retrying failed requests is safe.
FEATURED COURSES
5 Courses of the Week
✅ Microsoft Data Analyst Certificate: Learn to transform data into meaningful insights using Power BI. Master data preparation, modeling with Star schema, and DAX calculations. Create compelling dashboards to drive data-based decision making across organizations.
✅ Google UX Design Certificate: Gain professional UX design skills through hands-on projects using Figma and Adobe XD. Learn the complete design process from user research to prototyping and usability testing. Build a portfolio with three end-to-end projects to showcase your skills to employers.
✅ Meta Front-End Developer Certificate: Master interactive web development with HTML5, CSS, and JavaScript. Learn in-demand skills including React, Bootstrap, GitHub, and professional page layouts. Complete practical projects culminating in a capstone web application to demonstrate your expertise.
✅ Applied Data Science Specialization: Develop practical Python skills using NumPy, Pandas, and visualization libraries. Master predictive modeling, model selection, and compelling data storytelling techniques. Complete real-world projects including financial data analysis and flight reliability monitoring dashboards.
✅ Essential Linear Algebra for Data Science: Acquire fundamental linear algebra concepts specifically tailored for data science applications. Learn approachable methods without unnecessary proofs and complexity. Build a strong mathematical foundation to prepare for advanced data science studies.
HEARD OF THE CODE?
What 100K+ Engineers Read to Stay Ahead
Your GitHub stars won't save you if you're behind on tech trends.
That's why over 100K engineers read The Code to spot what's coming next.
Get curated tech news, tools, and insights twice a week
Learn about emerging trends you can leverage at work in just 10 mins
Become the engineer who always knows what's next
NEWS
This Week in the Tech World

OpenAI Testing Ads in ChatGPT: OpenAI announced it will test ads in free and Go tiers for US users. Ads appear below responses and won't influence answers. A new $8/month Go tier also launched.
Zipline Raises $600M, Valued at $7.6B: Drone delivery startup Zipline raised $600M and will expand to Houston and Phoenix. The company has surpassed 2 million commercial deliveries worldwide.
Deepgram Raises $130M at $1.3B Valuation: Voice AI startup Deepgram raised a Series C led by AVP. The company provides real-time transcription and speech APIs for enterprise applications.
Nvidia Invests in AI Inference Startup: Nvidia joined a funding round in Baseten, an AI startup focused on running models in production. The move signals Nvidia's bet on inference economics.
Xiaomi Cuts Shipment Targets: Xiaomi and Transsion are reducing 2026 shipment targets amid a global memory supply crunch. AI-era demand is pressuring memory and storage supply chains.
Microsoft Patches Windows 11 Bug: Microsoft released an out-of-band fix after a January security update caused shutdown issues on some Windows 11 devices.
Sony Cedes Bravia TV to TCL: Sony is handing control of its Bravia TV brand operations to TCL under a strategic partnership. The move highlights margin pressure in consumer electronics.
UK Eyes Under-16 Social Media Ban: UK ministers are evaluating a model for an under-16 social media ban similar to Australia's, signaling a harder policy turn on youth online safety.
FuriosaAI Seeks $500M Funding: South Korea's FuriosaAI is raising up to $500M ahead of a potential IPO, positioning itself as an Nvidia challenger in the AI accelerator market.
BONUS
Just for laughs 😏

WE NEED YOU!
👋 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,



