• InstaByte
  • Posts
  • Amazon and OpenAI sign $38B deal

Amazon and OpenAI sign $38B deal

ALSO: Database Connection Pooling

In partnership with

Welcome back!

This week, we’ll solve one of the most popular interview problems. It has been asked more than 100 times in last 6 months.

Today we will cover:

  • Search in Rotated Sorted Array

  • Database Connection Pooling

Read time: under 4 minutes

CODING CHALLENGE

Search in Rotated Sorted Array

There is an integer array nums sorted in ascending order (with distinct values).

Prior to being passed to your function, nums is possibly rotated at an unknown pivot index k (1 <= k < nums.length) such that the resulting array is [nums[k], nums[k+1], ..., nums[n-1], nums[0], nums[1], ..., nums[k-1]] (0-indexed). For example, [0,1,2,4,5,6,7] might be rotated at pivot index 3 and become [4,5,6,7,0,1,2].

Given the array nums after the possible rotation and an integer target, return the index of target if it is in nums, or -1 if it is not in nums.

You must write an algorithm with O(log n) runtime complexity.

Example 1:

Input: nums = [4,5,6,7,0,1,2], target = 0
Output: 4

Example 2:

Input: nums = [4,5,6,7,0,1,2], target = 3
Output: -1

Solve the problem here before reading the solution.

GET PRIVATE EMAIL

Free, private email that puts your privacy first

A private inbox doesn’t have to come with a price tag—or a catch. Proton Mail’s free plan gives you the privacy and security you expect, without selling your data or showing you ads.

Built by scientists and privacy advocates, Proton Mail uses end-to-end encryption to keep your conversations secure. No scanning. No targeting. No creepy promotions.

With Proton, you’re not the product — you’re in control.

Start for free. Upgrade anytime. Stay private always.

SOLUTION

To solve this problem, we can use a modified Binary Search algorithm. When we do Binary Search, we divide the array into two halves: left half and right half.

In a rotated sorted array, at least one half (left or right) will always be sorted. First, we need to find which half of the array is sorted.

Once we identify the sorted half, we can check if our target lies within its range. If it does, we search in that half. If it doesn't, we search in the other half.

This process continues until we either find the target or determine it's not in the array.

The time complexity of this solution is O(log n) as we are using Binary Search.

WHAT'S NEW IN AI?

Go from AI overwhelmed to AI savvy professional

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

SYSTEM DESIGN

Database Connection Pooling

Opening and closing database connections for every request can significantly slow down your application. Each new connection requires TCP handshake, authentication, and memory allocation, all of which take time. Connection pooling solves this by maintaining a pool of reusable database connections.

Here's how connection pooling works. When your application starts, it creates a set of database connections and keeps them ready to use. When your code needs to query the database, it borrows a connection from the pool, uses it, and returns it back instead of closing it. This makes database operations much faster since connections are reused rather than created from scratch.

Here are some key practices to get the most out of connection pooling:

Pool Size: Start with pool size = number of CPU cores * 2. This gives enough connections to handle concurrent requests without wasting resources. Monitor connection usage and adjust if needed.

Connection Lifetime: Set a maximum lifetime for connections (usually a few hours) to prevent issues with stale connections. The pool will automatically replace old connections with fresh ones.

Timeout Settings: Set reasonable timeouts for both getting a connection from the pool and executing queries. This prevents requests from hanging when the pool is exhausted or queries are taking too long.

Monitoring: Track metrics like connection wait time, pool utilization, and connection errors. These help identify if your pool needs tuning.

SIDE HUSTLE WITH AI

Turn AI Into Your Income Stream

The AI economy is booming, and smart entrepreneurs are already profiting. Subscribe to Mindstream and get instant access to 200+ proven strategies to monetize AI tools like ChatGPT, Midjourney, and more. From content creation to automation services, discover actionable ways to build your AI-powered income. No coding required, just practical strategies that work.

FEATURED COURSES

5 Courses of the Week

 Meta Front-End Developer Professional 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, creating a front-end web application that showcases your new coding and design capabilities.

 Amazon Junior Software Developer Certificate: Dive into real-world software development through a comprehensive 7-course series. You'll create desktop applications with integrated data handling and GUI features, building a substantial portfolio that demonstrates your technical skills to potential employers.

 Grokking the Modern System Design Interview: The ultimate guide to the System Design Interview – developed by Meta & Google engineers. Master distributed system fundamentals, and practice with real-world interview questions & mock interviews.

 Generative AI for Everyone: The course includes hands-on exercises in prompt engineering, real-world applications, and advanced AI implementation techniques. It aims to equip everyone with skills to effectively use AI in daily work and understand its broader impacts.

 Python Data Fundamentals: Master essential Python data analysis skills through hands-on practice with Pandas, Seaborn, and Statistics.

NEWS

This Week in the Tech World

AWS and OpenAI $38B Deal: OpenAI signed a $38 billion deal with AWS to access hundreds of thousands of Nvidia GPUs. The seven-year partnership marks OpenAI's biggest move away from Microsoft as its exclusive cloud provider.

AMD confirms Zen 5 security flaw: AMD disclosed a high-severity vulnerability in Zen 5 CPUs affecting RDSEED random number generation, potentially compromising cryptographic keys.

Nvidia Hits $5 Trillion: Nvidia became the first company ever to reach $5 trillion in market value. The AI chip giant crossed the milestone just three months after hitting $4 trillion, driven by huge demand for its GPUs.

GitHub Launches Agent HQ: GitHub unveiled Agent HQ, a platform letting developers manage coding agents from OpenAI, Google, Anthropic and others in one place. The tool addresses the chaos of juggling multiple AI coding assistants.

Tech Giants Boost AI Spending: Google, Microsoft, Meta and Amazon collectively raised capital expenditure forecasts above $380 billion for 2025. The massive spending reflects continued heavy investment in AI infrastructure.

MongoDB CEO steps down: Dev Ittycheria retires after 11 years as MongoDB CEO. Cloudflare's CJ Desai takes over, bringing deep experience scaling enterprise software platforms.

Google Pulls AI Over False Claims: Google removed its Gemma AI model after it falsely generated rape allegations against Senator Marsha Blackburn. The incident highlights ongoing AI hallucination problems plaguing the industry.

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,