🚀 Day 19/100 – #100DaysOfCode Challenge Today I worked on an important concept in Binary Search — Lower Bound 🔍 💡 Problem Statement: Find the first index in a sorted array where the value is greater than or equal to a given target (x). ⚡ Key Learning: Lower Bound helps in efficient searching in sorted arrays Instead of linear search (O(n)), we can optimize to O(log n) using Binary Search Very useful in competitive programming & real-world applications 🧠 Approach: Apply Binary Search Store the potential answer Move left to find the smallest valid index ✅ Example: Input: [1,2,2,3], x = 2 Output: 1 💻 What I Practiced Today: Binary Search optimization Edge case handling Writing clean and efficient code 📈 Progress: Improving problem-solving skills step by step! #Day19 #100DaysOfCode #DSA #BinarySearch #CodingJourney #Java #ProblemSolving #Learning
Binary Search Optimization with Lower Bound
More Relevant Posts
-
📅 Day 17/100 – LeetCode Challenge 🔹 Problem: 268. Missing Number Today I solved an easy but important array problem where I had to find the missing number from a given range [0, n]. 💡 My Approach: Calculated the expected sum of numbers from 0 to n using formula Calculated the actual sum of elements in the array Subtracted both to find the missing number 🧠 Code Logic: Expected Sum = n * (n + 1) / 2 Missing Number = Expected Sum - Actual Sum 📌 What I Learned: How to use mathematical formulas to optimize problems Avoid unnecessary loops or sorting Improved understanding of array traversal Learned an efficient O(n) solution 🚀 Key Takeaway: Using math-based logic can simplify problems and make solutions faster and cleaner. #Day17 #100DaysOfCode #Java #LeetCode #DSA #Learning
To view or add a comment, sign in
-
-
🚀 Day 44/100 Today’s problem: Reverse Vowels of a String. 🔹 Problem Summary: Given a string, reverse only the vowels while keeping other characters in the same position. 🔹 Approach I Used: I applied the Two Pointer Technique: - One pointer from the start, one from the end - Move both until vowels are found - Swap them and continue 🔹 Key Learning: ✔ Two pointers can simplify string problems a lot ✔ Always break the problem into smaller steps ✔ Practice improves pattern recognition. 🔹 Example: Input: "IceCreAm" Output: "AceCreIm" 🔹 Time Complexity: O(n) 🔹 Space Complexity: O(n) Consistency is the key 🔑 — showing up every day! #Day44 #CodingJourney #DSA #Java #Learning #100DaysOfCode
To view or add a comment, sign in
-
-
Day 22/100 — LeetCode Today’s problem: Happy Number 😊 At first, it looked like a simple math problem… but it turned out to be about patterns and repetition. 🔍 What I learned: Break a number into digits using % 10 and / 10 Square each digit and keep adding Repeat the process until: You reach 1 → Happy Number ✅ Or it starts repeating → Not Happy ❌ 🧠 Key Insight: This problem is actually about cycle detection — if a number repeats, it will never reach 1. ⚡ Simple Example: 19 → 82 → 68 → 100 → 1 ✅ 💡 Takeaway: Sometimes problems that look like math are really about loops and patterns. Small steps every day → Big improvement 🚀 #Day22 #100DaysOfCode #LeetCode #Java #DSA #CodingJourney
To view or add a comment, sign in
-
-
🚀 Day 11/100 — #100DaysOfLeetCode Consistency continues — one problem closer to better problem-solving skills 💻🔥 ✅ Problem Solved: 🔹 LeetCode 1423 — Maximum Points You Can Obtain from Cards 💡 Concepts Used: Sliding Window Technique Complementary Subarray Thinking 🧠 Key Learning: Instead of directly choosing k cards from both ends, I learned to think differently — find the minimum sum subarray of size n - k and subtract it from the total sum. This transformation converts a complex decision problem into a clean sliding window optimization. ⚡ Takeaway: Sometimes optimization comes from changing perspective, not increasing complexity. Continuing the journey 🚀 #100DaysOfLeetCode #LeetCode #DSA #SlidingWindow #Algorithms #Java #ProblemSolving #CodingJourney #LearningInPublic
To view or add a comment, sign in
-
-
#CodeEveryday — My DSA Journey | Day 3 🧩 Problem Solved: Combination Sum III (LeetCode #216) 💭 What I Learned: Used backtracking to find all possible combinations of k numbers (1–9) that sum up to a target n. At each step: ✔️ Decided whether to include the current number ✔️ Reduced both the remaining sum (n) and count (k) ✔️ Ensured each number is used only once by moving to the previous index Applied constraints effectively to prune recursion when: Remaining sum becomes negative Required count becomes invalid This improved my understanding of handling multiple constraints (sum + size) simultaneously in recursion. ⏱ Time Complexity: O(C(9,k) 🧠 Space Complexity: O(k) (recursion depth) ⚡ Key Takeaways: ✔️ Backtracking with multiple constraints requires careful pruning ✔️ Fixed input size can significantly reduce complexity ✔️ Choosing + skipping pattern helps explore all valid combinations 💻 Language Used: Java ☕ 📘 Concepts: Backtracking · Recursion · Combinations · Constraint Handling #CodeEveryday #DSA #LeetCode #Java #Backtracking #ProblemSolving #Algorithms #CodingJourney #Consistency 🚀
To view or add a comment, sign in
-
-
🚀 Day 25 of Consistency – LeetCode Journey Today I solved Problem 268: Missing Number on LeetCode. 💡 Approach I Used (Optimal – Math Based): First, I calculated the expected sum of numbers from 0 to n using the formula: 👉 n * (n + 1) / 2 Then: ✅ Calculated the actual sum of all elements in the array ✅ Subtracted actual sum from expected sum 🎯 The result gives the missing number 🧠 Key Learning: This problem shows how a simple mathematical formula can optimize performance and reduce complexity. ⚡ Complexity: • Time: O(n) • Space: O(1) 📌 Consistency is building my problem-solving mindset step by step. #Day25 #LeetCode #DSA #Java #CodingJourney #Consistency #ProblemSolving
To view or add a comment, sign in
-
-
🚀Solved Validate Stack Sequences by simulating the stack using a simple array instead of relying on built-in stack classes. This helped reduce overhead and kept the operations efficient. Focused on writing clean logic with optimal time complexity. 😊 Result: 💯 Achieved 0 ms runtime beating 100% of submissions, with memory usage around 45.52 MB performing in the top percentile. 💥 #LeetCode #DSA #Java #Coding #ProblemSolving #Preparation #Anurag_University 🚀🚀
To view or add a comment, sign in
-
-
🚀 Day 21/100 Days of Code 📌 Problem Solved: Search Insert Position(Leetcode 35) Today I worked on a classic Binary Search problem that goes beyond just finding an element. The task was to return the index if the target exists, otherwise return the position where it should be inserted to maintain sorted order. 💡 Approach: Used Binary Search to reduce time complexity from O(n) to O(log n). By adjusting the search space using low and high, we can efficiently narrow down the correct position. 📈 What I learned: • Importance of handling edge cases • Writing optimal solutions instead of brute force • Deep understanding of how Binary Search works internally Every day is one step closer to mastering DSA 💪 #Day21 #100DaysOfCode #DSA #BinarySearch #Java #ProblemSolving #CodingJourney
To view or add a comment, sign in
-
-
DSA Day 20 – Frequency Counting with Strings Today I solved the “Ransom Note” problem on LeetCode. Problem: Check whether the ransomNote string can be constructed using letters from the magazine string, where each letter can be used only once. Approach Used: -> Counted frequency of characters in ransomNote -> Counted frequency of characters in magazine -> Compared required characters with available characters -> If any required count was greater than available count → false Time Complexity: -> O(n + m) Space Complexity: -> O(1) (Only lowercase English letters / limited character set) Key Learning: -> Frequency counting works not only for arrays, but also for strings -> HashMap helps compare required vs available resources efficiently -> Always check constraints, because they can reduce space complexity What I Realized: Many string problems are actually counting problems in disguise. The better you recognize patterns, the faster you solve problems. Thanks to Pulkit Aggarwal sir for guiding me in DSA and helping me understand problem-solving patterns. Consistency continues, one problem every day. #DSA #LeetCode #Java #ProblemSolving #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
Explore related topics
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