A LeetCode Daily Series — Day 2

Ritesh Shakya
Cerulearn
Published in
5 min readMar 12, 2024

--

Today’s problem is called “Missing Number”

Welcome to day two of my LeetCode adventure! Today’s problem is called “Missing Number” and it asks us to find the only number missing from a given array containing distinct numbers in a specific range.

https://leetcode.com/problems/missing-number/

If you’re just joining us, it might be helpful to catch up on the previous entries. Want to see more problem-solving techniques? Follow me on Medium!

Let’s dive in!

Understanding the Problem

We’re given an array nums containing n distinct numbers. These numbers fall within a specific range, from 0 to n. However, one number from this range is missing from the array. Our task is to find that missing number.

For example, if nums = [3, 0, 1], n (the length of the array) is 3. This means the expected range is 0 to 3. Since 2 is missing from the array, that's our answer.

Brute Force Approach

--

--

Ritesh Shakya
Cerulearn

I strive for daily self-improvement. Currently building ceruai.com.