Solved LeetCode 704 Binary Search

🚀 Day 11 of My LeetCode Journey – Solved Binary Search! 💻✨ Today I worked on LeetCode #704 – Binary Search ✅ This is one of those classic problems that every developer comes across during interview preparation, and solving it really helped me strengthen my fundamentals. 📌 What the problem is about Given a sorted array and a target value, the task is to find the index of that target. If the target is not present, return -1. Example: nums = [-1,0,3,5,9,12] target = 9 ✅ Output: 4 🔍 My approach Instead of checking every element one by one, I used Binary Search. The idea is simple: Find the middle element Compare it with the target If target is greater → search right half If smaller → search left half Repeat until found This reduces the search space by half every time 🚀 What I really like about this problem is how powerful the logic is. A simple idea, but very efficient. 💡 Key takeaway This problem reminded me that understanding the right approach matters more than writing long code. ⏱ Complexity Time Complexity: O(log n) Space Complexity: O(1) Slowly building strong DSA fundamentals, one problem at a time 🔥 #LeetCode #Python #BinarySearch #DSA #ProblemSolving

  • graphical user interface, text

To view or add a comment, sign in

Explore content categories