Day12 of leetcode 100days 💡 Problem Solved: Binary Search (LeetCode 704) 👉 Key Idea: Work on a sorted array, compare the middle element, and eliminate half of the search space each time. Takeaways: ✔️ Always use low + (high - low)/2 to avoid overflow ✔️ Loop condition should be low <= high ✔️ Works only on sorted arrays ✔️ Foundation for advanced problems like rotated arrays & bounds Binary Search is not just a problem — it’s a pattern that unlocks multiple interview questions. #DataStructures #Algorithms #Java #CodingInterview #LeetCode #BinarySearch #DSA #SoftwareEngineering #toronto #tech #2026 #sde #canada #tech #100daysleetcode #coders
Binary Search LeetCode 704 Solution
More Relevant Posts
-
LeetCode — But Did You Think About the How? #ContainsDuplicate | NeetCode 150 Most devs solve "Contains Duplicate" - https://lnkd.in/gq84sj37 and move on. But this problem is a great lens for thinking about trade-offs — and that's exactly what interviewers are watching for. Here are my two solutions: Solution 1 — Sort + Linear Scan class Solution { public boolean hasDuplicate(int[] nums) { Arrays.sort(nums); for (int i = 1; i < nums.length; i++) { if (nums[i] == nums[i - 1]) return true; } return false; } } Time: O(n log n) | Space: O(1) (in-place sort) Solution 2 — Stream + Distinct class Solution { public boolean hasDuplicate(int[] nums) { return Arrays.stream(nums).distinct().count() < nums.length; } } Time: O(n) | Space: O(n) My repository - https://lnkd.in/g_Ke_eqR Key Insight: One liner looks cleaner. But it costs you extra memory. The sort-based approach trades time for space — and modifies the original array. Neither is universally "better." The right answer depends on your constraints: → Memory-constrained system? Go with Sort. → Read-only array or immutable input? Stream wins. → Need early exit on first duplicate? Both support it — but stream is lazy, so it does too This is the kind of thinking that separates good developers from great ones in interviews. What's your go-to approach? Drop it below #Java #LeetCode #NeetCode #DSA #CodingInterview #SpringBoot #SoftwareEngineering #ProblemSolving #100DaysOfCode
To view or add a comment, sign in
-
-
🚀 200 problems on LeetCode — but the real growth isn’t just a number. Somewhere along the journey, my approach changed. I stopped asking: ❌ “How do I solve this problem?” And started asking: ✅ “Why does this approach work?” ✅ “What pattern is behind this?” ✅ “Where else can I apply this?” That shift made all the difference. 📈 What I’ve built so far: ✔ Stronger problem-solving mindset ✔ Better understanding of data structures ✔ Pattern recognition across problems ✔ More structured debugging approach Now, I don’t just solve problems — I understand them. Still learning. Still improving. But now with clarity and direction. #LeetCode #DSA #ProblemSolving #CodingJourney #Java
To view or add a comment, sign in
-
-
🧠 LeetCode POTD — Simple Problem, One Small Trick 2515. Shortest Distance to Target String in a Circular Array At first glance, this feels very straightforward. 👉 Find all positions of target 👉 Compute distance from startIndex (from both directions) 👉 Take the minimum Done. But then I thought… Why am I finding all positions first? We're allowed to move left or right, one step at a time. ━━━━━━━━━━━━━━━━━━━ 💡 So instead, I started from startIndex and expanded in both directions simultaneously. 📌 The moment we hit the target → that distance is already the minimum. No need to check anything else. ━━━━━━━━━━━━━━━━━━━ The only tricky part? Handling the circular nature of the array. 💡 Clean trick — both directions in the same loop: → Right: (start + i) % n → Left: (start - i + n) % n That's it. ━━━━━━━━━━━━━━━━━━━ 📌 What I liked about this problem: Not about complexity. Not about fancy algorithms. Just about finding a clean way to move in both directions. ✅ Sometimes the hardest part isn't solving… ✅ It's writing a simple idea cleanly. Curious if someone approached this differently 👀 #LeetCode #ProblemSolving #SoftwareEngineering #DSA #C++ #Java #SDE
To view or add a comment, sign in
-
-
Most software projects don’t fail because of bad code. They fail because there’s no real ownership. That’s why companies work with software development partners, not task-based vendors. At D2 WebTech, we own the product end-to-end. Let’s build it right. #SoftwareDevelopment #TechPartner #Python #ReactJS
To view or add a comment, sign in
-
Day 17 of #50DaysOfLeetCode Today’s problem: Move Zeroes (LeetCode) Problem Statement: Move all 0s to the end of the array while maintaining the relative order of non-zero elements — all done in-place. Approach: Used the Two Pointer Technique to efficiently rearrange elements in a single pass without extra space. Key Insight: Track the position of the next non-zero element and swap only when necessary. 🔹 Complexity: - Time: O(n) - Space: O(1) #LeetCode #Java #DataStructures #CodingJourney #ProblemSolving #100DaysOfCode #DeveloperLife
To view or add a comment, sign in
-
-
The secret to surviving as a software engineer until you are fifty isn't endlessly chasing the latest frameworks; it is deliberately choosing to become profoundly boring. While the industry relentlessly pushes novelty through hype cycles, the uncomfortable reality is that engineers who spend their twenties rewriting stacks every two years to stay "modern" end up exhausted, having wasted years mastering ephemeral tools that inevitably died. In contrast, those who focused on durability—embracing a 30-year-old Java ecosystem with decades of established solutions or a 28-year-old PostgreSQL database with zero production surprises—are the ones actively shipping core enterprise systems in 2026. True technical depth compounds while novelty does not; the Fortune 500 budget isn't going toward whatever just launched at YC Demo Day, but rather to battle-tested technologies like Kafka, Spring Boot, and Java. Ultimately, bragging about only working on cutting-edge tech is a flex that ages terribly, because while building your skill stack for the next interview might make you look impressive at thirty, mastering "boring" technology is the actual foundation of innovation that will make you indispensable at fifty.
To view or add a comment, sign in
-
-
Solving LeetCode Problem | Day 6 • Problem: Reverse Linked List | LeetCode 206 • Approach: Used an iterative approach with three pointers: prev, curr, and next. Started from the head and reversed the direction of each node one by one by updating links: Stored next node Reversed current node’s pointer Moved all pointers forward This continues until the list is fully reversed, and prev becomes the new head. Key Insight: The tricky part is not losing the next node while reversing links. If you mess that up, the list is gone. • Time Complexity: O(n) • Space Complexity: O(1) #leetcode #dsa #algorithms #datastructures #coding #programming #java #linkedlist #problemsolving #tech #softwareengineering #developer #100daysofcode
To view or add a comment, sign in
-
-
100 Leetcode Problems solved. When I started, even “easy” problems felt confusing. I used to jump straight into coding and get stuck more often than not. Over time, I changed my approach. Instead of rushing to solutions, I started focusing on: 🔹breaking problems down before coding 🔹identifying patterns (especially in stacks, arrays, and linked lists) 🔹understanding time & space complexity 🔹learning how to optimize brute force approaches That shift made a big difference. Now, I’m not just solving problems — I’m thinking more like how I would in an interview setting: “How can I explain this clearly?” “Is this the most optimal approach?” “What edge cases am I missing?” 100 is still just the beginning, but it feels good to see progress from where I started. Next goal: improve problem-solving speed + consistency, and keep strengthening core DSA concepts. If you're on the same path — keep going. It’s slow, but it adds up. #LeetCode #DSA #InterviewPrep #ProblemSolving #Java #SoftwareEngineering
To view or add a comment, sign in
-
-
⚡ Code is Easy. Thinking is Hard. Over time, I’ve realized that writing code is just one part of being a developer. The real challenge is how you think before you write it. Understanding the problem, designing the right approach, and considering scalability, performance, and edge cases—that’s where the real engineering happens. Lately, I’ve been focusing more on: 🔹 Breaking down complex problems 🔹 Writing code that’s easy to maintain 🔹 Thinking about long-term impact, not just quick fixes Because good code works. But great code lasts. Always learning, always improving 🚀 #SoftwareEngineering #FullStackDeveloper #Java #SystemDesign #CleanCode #GrowthMindset
To view or add a comment, sign in
-
I spent 3 hours debugging a single line of code last week. Not because I had to. Because I needed to understand why. Here's what I mean: Most engineers fix bugs and move on. But I went down the rabbit hole — traced the call stack, read the source code, understood the memory layout. That's when I realized: You don't truly learn something until you've taken it apart. Example → Binary search. I'd used it hundreds of times. Passed LeetCode problems. Moved on. Then one day I asked myself: "Why does mid = lo + (hi - lo) / 2 instead of (lo + hi) / 2?" Turns out — integer overflow. A bug that crashed a Java binary search in production at Google... for 9 years before anyone noticed. That one question unlocked a depth of understanding no tutorial ever gave me. The engineers who stand out aren't the ones who know the most answers. They're the ones who ask the most uncomfortable questions. (#SoftwareEngineering #TechCareer #LearningInPublic #CareerGrowth #CodingLife #BinarySearch #MindsetMatters #AlwaysLearning #SoftwareDeveloper #TechJobs #SDEJobs #SeattleTech #SeniorSoftwareEngineer #TechRecruiter) What's a concept you thought you knew — until you really dug in?
To view or add a comment, sign in
More from this author
Explore related topics
- LeetCode Array Problem Solving Techniques
- Leetcode Problem Solving Strategies
- Approaches to Array Problem Solving for Coding Interviews
- Common Algorithms for Coding Interviews
- Problem Solving Techniques for Developers
- Solving Sorted Array Coding Challenges
- Prioritizing Problem-Solving Skills in Coding Interviews
- Strategies for Solving Algorithmic Problems
- Why Use Coding Platforms Like LeetCode for Job Prep
- How to Use Arrays in Software Development
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