🚀 Day 58/180 | #180DaysOfCode 📍 LeetCode | 💻 Java Solved: 278. First Bad Version Used binary search on answer space to efficiently find the first bad version while minimizing API calls. ⏱️ Time Complexity: O(log n) 📦 Space Complexity: O(1) Strengthening understanding of binary search optimization and decision-based problems. 💪 Consistency continues 🚀 #DSA #LeetCode #Java #CodingJourney #Consistency
Optimizing Binary Search for First Bad Version
More Relevant Posts
-
🚀 Day 65/180 | #180DaysOfCode 📍 LeetCode | 💻 Java Solved: 2535. Difference Between Element Sum and Digit Sum of an Array Used a single loop + digit extraction approach to calculate both element sum and digit sum efficiently. ⏱️ Time Complexity: O(n × d) 📦 Space Complexity: O(1) Strengthening understanding of number manipulation and digit-based operations. 💪 Consistency continues 🚀 #DSA #LeetCode #Java #CodingJourney #Consistency
To view or add a comment, sign in
-
-
🚀 Day 47/180 | #180DaysOfCode 📍 LeetCode | 💻 Java Solved: 448. Find All Numbers Disappeared in an Array Used an in-place marking technique by treating indices as a hash map and marking visited numbers as negative to identify missing elements. ⏱️ Time Complexity: O(n) 📦 Space Complexity: O(1) (excluding output list) Strengthening understanding of array manipulation and in-place hashing tricks. 💪 Consistency continues 🚀 #DSA #LeetCode #Java #CodingJourney #Consistency
To view or add a comment, sign in
-
-
🚀 Day 48/180 | #180DaysOfCode 📍 LeetCode | 💻 Java Solved: 1534. Count Good Triplets Used a brute-force triple nested loop to check all possible triplets and validate the given conditions using absolute differences. ⏱️ Time Complexity: O(n³) 📦 Space Complexity: O(1) Strengthening understanding of nested loop patterns and condition-based filtering. 💪 Consistency continues 🚀 #DSA #LeetCode #Java #CodingJourney #Consistency
To view or add a comment, sign in
-
-
Day 88 - LeetCode Journey Solved LeetCode 24: Swap Nodes in Pairs in Java ✅ This problem is a great exercise in pointer manipulation in linked lists. Instead of changing values, I swapped the actual nodes by carefully adjusting the next pointers. Using a dummy node made the process much cleaner and helped handle edge cases smoothly. Step by step, I swapped pairs while moving forward in the list. Key takeaways: • Deep understanding of pointer manipulation • Importance of dummy node in linked list problems • Clean handling of edge cases • Iterative approach for swapping nodes ✅ All test cases passed ⚡ Efficient O(n) time and O(1) space Linked list problems like this really sharpen your fundamentals 🔥 #LeetCode #DSA #Java #LinkedList #Pointers #ProblemSolving #CodingJourney #InterviewPrep #Consistency #100DaysOfCode
To view or add a comment, sign in
-
-
🚀 Day 46/180 | #180DaysOfCode 📍 LeetCode | 💻 Java Solved: 2315. Count Asterisks Used a boolean flag approach to track whether the current position is inside a pair of '|' and count only the valid '*' outside those sections. ⏱️ Time Complexity: O(n) 📦 Space Complexity: O(1) Strengthening understanding of state-based string traversal and conditional counting. 💪 Consistency continues 🚀 #DSA #LeetCode #Java #CodingJourney #Consistency
To view or add a comment, sign in
-
-
🚀 Day 57/180 | #180DaysOfCode 📍 LeetCode | 💻 Java Solved: 242. Valid Anagram Used a HashMap frequency counting approach (Unicode-safe using code points) to compare character frequencies of both strings. ⏱️ Time Complexity: O(n) 📦 Space Complexity: O(n) Strengthening understanding of string frequency analysis and Unicode handling. 💪 Consistency continues 🚀 #DSA #LeetCode #Java #CodingJourney #Consistency
To view or add a comment, sign in
-
-
Day 62 of #100DaysOfLeetCode 💻✅ Solved #219. Contains Duplicate II problem in Java. Approach: • Used two nested loops to compare elements within range k • For each element, checked next k elements • If any duplicate is found within distance k, returned true • If no such pair exists, returned false Key Learning: ✓ Practiced checking duplicates within a given range ✓ Strengthened understanding of array traversal with conditions ✓ Learned the importance of optimizing nested loop solutions Learning one problem every single day 🚀 #Java #LeetCode #DSA #Arrays #ProblemSolving #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
Day 98 - LeetCode Journey Solved LeetCode 20: Valid Parentheses in Java ✅ A classic stack problem that looks simple but tests your attention to detail. The idea is straightforward: Push opening brackets into stack and match them correctly when a closing bracket appears. If anything mismatches → invalid. Clean logic, zero confusion 💡 Key takeaways: • Stack fundamentals • Matching pairs efficiently • Handling edge cases (empty stack, wrong order) • Writing clean conditional logic ✅ All test cases passed ⚡ O(n) time and O(n) space Sometimes basics like this are the real building blocks of strong DSA 🔥 #LeetCode #DSA #Java #Stack #ProblemSolving #CodingJourney #InterviewPrep #Consistency #100DaysOfCode
To view or add a comment, sign in
-
-
Day 75 of #100DaysOfLeetCode 💻✅ Solved #278. First Bad Version problem in Java. Approach: • Used Binary Search to minimize API calls • Narrowed search space using isBadVersion(mid) • Moved left/right pointers based on condition • Final position gives the first bad version Performance: ✓ Runtime: 16 ms (Beats 10.29% submissions) ✓ Memory: 42.16 MB (Beats 42.59% submissions) Key Learning: ✓ Practiced Binary Search with API-based problems ✓ Improved optimization by reducing unnecessary calls ✓ Strengthened problem-solving using monotonic conditions Learning one problem every single day 🚀 #Java #LeetCode #DSA #BinarySearch #ProblemSolving #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
🚀 Day 8/30 — LeetCode Challenge Solved "Swap Nodes in Pairs" on LeetCode using Java. This problem focuses on "rearranging node connections", not just swapping values — making pointer handling critical. Used a dummy node approach to simplify edge cases and ensure smooth pair-wise swapping. ✅ Key takeaway: Linked list problems are less about logic and more about **precise pointer management** — one wrong link can break the entire structure. #LeetCode #Java #LinkedList #DataStructures #ProblemSolving #Consistency
To view or add a comment, sign in
-
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