🚀 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
Solved LeetCode 704 Binary Search
More Relevant Posts
-
🚀 Just solved the Power of Two problem on LeetCode — and here’s a quick look at my approach 👇 Instead of jumping straight into bit manipulation, I focused on a simple iterative logic: 🔹 Start from 2 🔹 Keep multiplying by 2 🔹 Check if we reach the given number 🔹 If yes → it’s a power of two ✅ 🔹 If we overshoot → it’s not ❌ 💡 This approach emphasizes clarity over cleverness — building intuition step-by-step before optimizing further. While there are more optimized solutions (like bit tricks), I believe: 👉 Strong fundamentals > premature optimization 📊 Result: ✔️ 100% runtime efficiency ✔️ Clean and readable logic Always aiming to improve not just what I solve, but how I think 💭 #LeetCode #DSA #ProblemSolving #Python #CodingJourney #100DaysOfCode #WomenInTech #FutureEngineer #TechGrowth #Consistency #LearnInPublic #CodingLife #SoftwareEngineering #DeveloperMindset
To view or add a comment, sign in
-
-
🚀 Day 5 of My LeetCode Journey – Solved Contains Duplicate! 💻✨ Today I solved LeetCode #217 – Contains Duplicate ✅ A popular Easy-level array problem often asked in coding interviews. 📌 Problem Statement Given an integer array nums, return true if any value appears at least twice in the array, otherwise return false. Example: nums = [1,2,3,1] ✅ Output: true 🔍 My Approach – Using Set I used Python’s built-in set() for an efficient solution. Convert the array into a set Compare the length of the original array with the set If lengths are different → duplicates exist Otherwise → all elements are unique 💡 Why This Works A set stores only unique elements, so any duplicate values are automatically removed. This made the solution short, clean, and optimized 🚀 💡 What I Learned This problem helped me strengthen: ✔ Arrays ✔ Hashing / Set usage ✔ Python built-in functions ✔ Efficient duplicate detection ✔ Interview coding logic ⏱ Complexity Time Complexity: O(n) Space Complexity: O(n) Small problems like this are great for building strong DSA fundamentals 🔥 #LeetCode #Python #DSA #Arrays #Hashing #ProblemSolving #CodingJourney #SoftwareDeveloper #InterviewPreparation #Programming #100DaysOfCode #LearningInPublic
To view or add a comment, sign in
-
-
🚀 Day 19 of #DSAStreak 📌 Problem: Nth Node from End of Linked List 🧠 Problem Summary: Given a singly linked list, find the nth node from the end. 👉 Counting starts from the last node 👉 Return the value of that node 👉 No need to find index from start 💡 Approach: Two Pointer Technique 🔥 Instead of using multiple traversals ❌, we optimize using: ✔ Two pointers → fast & slow ✔ Move fast pointer n steps ahead ✔ Then move both pointers together ⚙ Key Logic: 👉 Maintain a gap of n nodes between fast and slow 👉 When fast reaches the end, slow automatically points to the nth node from last ⏱ Time Complexity: O(n) 💾 Space Complexity: O(1) 🚀 Key Takeaways: ✔ Single pass solution (efficient) ✔ No need to calculate length ✔ Pointer manipulation is key in linked list problems 💬 Important Insight: 👉 This problem is NOT about index 👉 It’s about position from the END of the list #DSA #LinkedList #Coding #InterviewPrep #100DaysOfCode #Python
To view or add a comment, sign in
-
-
Day 7 of #14DayPythonBootcamp 👨💻✨ Yesterday’s session was focused on pattern problems, one of the most important topics for coding interviews 🔥 We started from basic nested loop understanding and gradually moved to solving complex pattern problems using Python 💻🧠. This helped me clearly understand how rows and columns work internally in loops. I practiced multiple patterns like: • Star patterns ⭐ • Number grids 🔢 • Increasing & decreasing triangles 🔺 • Pyramid patterns • Alternating patterns (like 1 0 1 / 0 1 0) I also completed tasks such as: ✔️ Number Pyramid (1 → 1 2 → 1 2 3 …) ✔️ Repeated Number Triangle (1, 2 2, 3 3 3 …) ✔️ Binary pattern (1 0 1 pattern) This session really improved my logical thinking, loop control, and problem-solving skills 💪⚡. Pattern problems may look simple, but they are powerful for mastering nested loops and logic building. Feeling more confident and interview-ready step by step 🚀 #Python #PatternProblems #CodingJourney #ProblemSolving #LearningEveryday #CareerGrowth #JobReady #14DayPythonBootcamp #LearningInPublic #Codegnan
To view or add a comment, sign in
-
In my previous post, i talked about breaking code with one small change. This time? It gets worse. You write the code. 1 error. You fix the error. 12 new errors. And your screen is basically on fire. Every programmer has been here. Every single one. Here is the truth about errors in coding: Errors are not failure. They are feedback. Python does not hate you. It is telling you exactly what is wrong. Fixing one error exposing others means you are making progress. The code was always broken. Now you can finally see it. How to handle cascading errors like a professional: Fix from the top. The first error often causes all the others. Read the full error message. The answer is always in there. Do not fix everything at once. One error at a time. Take a break. Fresh eyes fix bugs faster than tired ones. Note: Debugging is not the obstacle. It is the job. #Python #Debugging #DataScience #LearnToCode #BeginnerCoder #Coding #StudentLife
To view or add a comment, sign in
-
-
Day 63 of my #100DaysOfCode challenge 🚀 Today I worked on generating all permutations of a string using recursion in Python. This is a fundamental problem to understand recursion + backtracking patterns, and it's very common in coding interviews. What the program does: • Takes a string as input • Generates all possible permutations • Uses recursive approach (no built-ins like itertools) • Returns all arrangements of characters Example (Input: "abc"): Permutations:['abc', 'acb', 'bac', 'bca', 'cab', 'cba'] Total permutations: 6 How the logic works: Recursive idea: 1. Fix one character at a time 2. Find permutations of remaining string 3. Combine fixed character with each permutation 4. Repeat until only one character is left Example breakdown: Fix 'a' → permute "bc" Fix 'b' → permute "ac" Fix 'c' → permute "ab" Why this is important: – Core concept for recursion & backtracking – Used in problems like: Anagrams Password generation Combination problems – Frequently asked in interviews – Builds strong problem-solving mindset Time Complexity: O(n!) Space Complexity: O(n!) Key Takeaways: – Recursive problem decomposition – Understanding permutations logic – Building solutions step-by-step – Avoiding built-in shortcuts for clarity #100DaysOfCode #Day63 #Python #Programming #Recursion #Backtracking #Permutations #Strings #Algorithms #DSA #CodingPractice #ProblemSolving #InterviewPrep #LearnByDoing #DeveloperJourney #Consistency #BTech #CSE #AIandML #VITBhopal #TechJourney
To view or add a comment, sign in
-
-
Day 59/60 of #GeekStreak60 💻 Here’s a simple-looking problem that tests your real understanding of strings + logic 👇 👉 Given a string, can you rearrange it to form a palindrome? Most people try permutations (❌ wrong approach — too slow) But the real trick is this: 🧠 Core Insight - Even length → all characters must appear even times - Odd length → only ONE character can have an odd count That’s it. That’s the whole game. 💡 Example: "baba" → ✅ Possible → "abba" "geeksogeeks" → ✅ Possible "geeksforgeeks" → ❌ Not possible 💭 Takeaway: Stop overcomplicating problems. Sometimes, the difference between ❌ brute force and ✅ optimal solution is just one observation. If you're preparing for DSA or interviews, master these patterns: ✔ Frequency counting ✔ Odd/even logic ✔ Bit manipulation Follow for more daily breakdowns 🚀 #geekstreak60 #npci #DSA #Python #CodingInterview #ProblemSolving #LearnToCode #TechJourney #GeekStreak
To view or add a comment, sign in
-
-
🚀 Day 26 of Consistency | #75DaysLeetCodeChallenge 🧠 Today’s Problem: Find Minimum in Rotated Sorted Array (#153) 💡 Key Learning: This problem builds deeper intuition for binary search on rotated arrays, where the sorted order is partially disturbed but still exploitable. ⚡ Approach: Use binary search to identify the unsorted portion Maintain left and right pointers If current subarray is already sorted → update result and break Find mid and update minimum If mid element ≥ left → move right side Else → move left side Keep updating the minimum element 🧠 Why this works: At least one half of the array is always sorted Binary search helps eliminate half search space each step Efficiently finds minimum in O(log n) time 🔥 Result: ✔️ Runtime: 0 ms (Beats 100%) 📈 This is a classic binary search variation and very important for mastering rotated array problems in interviews. A big thanks to Shivam Singh, Nikhil Yadav & Akshat Tiwari for this amazing challenge 🙌 Consistency is compounding. Keep going. 💪 #Day26 #LeetCode #DSA #CodingJourney #100DaysOfCode #Python #BinarySearch #Consistency
To view or add a comment, sign in
-
-
Practice. Practice. Practice. Lots of mock interviews and prep. There are tons of interview websites including leetcode, hackerrank. Leetcode is prob your best option for software engineer interview and hackerrank for python and sql prep. And the internet is full of ML and stats questions. Practice them.
To view or add a comment, sign in
-
-
📝 Why I deliberately write "boring" code: Fancy code is impressive. Boring code is reliable. What boring code looks like: ✅ Clear variable names (customer_count not cc) ✅ Small functions that do one thing ✅ Comments that explain WHY, not WHAT ✅ Consistent formatting ✅ Error handling for edge cases Who benefits? → Future me (6 months from now, I won't remember) → My teammates (they can actually read it) → Production (less surprises at 2 AM) Clever code makes you feel smart. Boring code makes you effective. Which do you prefer to maintain? #CodeQuality #Python #DataEngineering #CleanCode
To view or add a comment, sign in
Explore related topics
- Leetcode Problem Solving Strategies
- Problem Solving Techniques for Developers
- LeetCode Array Problem Solving Techniques
- Approaches to Array Problem Solving for Coding Interviews
- Prioritizing Problem-Solving Skills in Coding Interviews
- Strategies for Solving Algorithmic Problems
- Common Algorithms for Coding Interviews
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development