Day 20/100 🚀 | LeetCode Grind Cracked “Guess Number Higher or Lower” using Binary Search 🎯 Optimized the approach by narrowing down the search space efficiently with each guess — classic divide & conquer in action. 💡 Key Takeaway: When the search space is sorted and bounded, Binary Search is your best friend. ⚡ Runtime: 0 ms (Beats 100%) 📊 Efficient and clean implementation Consistency > Intensity. Showing up every day 💪 #Day20 #100DaysOfCode #LeetCode #DSA #BinarySearch #CodingJourney #Java #ProblemSolving
Cracking LeetCode's Guess Number Higher or Lower with Binary Search
More Relevant Posts
-
#Day360 of #1001DaysOfCode 📘 LeetCode Daily Challenge Problem: Search in a Binary Search Tree (LeetCode 700) 💡 Approach: Used the properties of a Binary Search Tree to efficiently search for a value. At each step: If the value is smaller, move to the left subtree If larger, move to the right subtree This reduces the search space at every step. ⏱ Time Complexity: O(h) 🧠 Space Complexity: O(h) Continuing daily consistency in problem solving 🚀 #DSA #Java #LeetCode #BinaryTree #ProblemSolving #Coding
To view or add a comment, sign in
-
-
🚀 Day 8 of #100DaysOfCode Solved: Maximum Product of Two Elements in an Array 💻 Today’s problem was all about optimizing logic and thinking smart instead of brute force. Instead of checking every pair, I focused on finding the two largest elements efficiently and used them to compute the result in a single pass 🔥 ✅ Time Complexity: O(n) ✅ Space Complexity: O(1) Small problems like these really sharpen problem-solving skills and reinforce the importance of clean, efficient code. Consistency is key — showing up every day, learning something new, and getting 1% better 💯 #DSA #Java #CodingJourney #LeetCode #ProblemSolving #Consistency #Day8#DSAwithEdSlash
To view or add a comment, sign in
-
-
Day 101 - LeetCode Journey Solved LeetCode 856: Score of Parentheses ✅ Looks tricky at first, but turns out to be a neat pattern problem. Instead of using a stack, used depth tracking + bit manipulation to calculate score efficiently. Core idea: Every "()" contributes 2^depth So just track depth and add score at the right moment. Key learnings: • Understanding pattern inside parentheses • Using depth instead of extra space • Bit manipulation for optimization ⚡ • Clean O(n) solution without stack ✅ All test cases passed ⚡ O(n) time | O(1) space Simple logic, powerful result 💡 #LeetCode #DSA #Stack #BitManipulation #Java #CodingJourney #ProblemSolving #InterviewPrep
To view or add a comment, sign in
-
-
Day 56 : Crushing Binary Trees on LeetCode 💡 Today’s live practical session in Alpha Plus 7.0 We focused on some of the most challenging Binary Tree questions on LeetCode, breaking down the logic behind them. What I practiced today: ✅ Tree Diameter: understand the logic to calculate the absolute longest path between any two nodes in the entire tree. ✅ Maximum Path Sum: Tackled a famous "Hard" level problem! Figured out how to find the path with the highest possible sum, even if it doesn't pass through the root. ✅ Target Deletion: Wrote the recursive code to systematically find and delete leaf nodes that match a specific target value. #BinaryTree #LeetCode #ProblemSolving #DSA #Java #SoftwareEngineering #100DaysOfCode #ApnaCollege
To view or add a comment, sign in
-
-
🚀 Day 87 — LeetCode Practice 🚀 Today’s focus was on ranking logic and nested iteration concepts. ✅ Problem solved today: 🔹 Relative Ranks 💡 Key learnings from today: • Understood how to determine ranks by comparing each element with others • Learned how counting higher scores helps assign positions • Strengthened concepts of nested loops and conditional logic • Explored how to map rankings into strings like Gold Medal, Silver Medal, Bronze Medal • Improved thinking on converting numeric logic into meaningful output 🧠 Approach used: Used a brute-force method where for each score, I counted how many scores are greater than it to determine its rank. ⚡ Time Complexity: O(n²) 📦 Space Complexity: O(n) 📈 Progress: Staying consistent and improving problem-solving step by step! #Day87 #LeetCode #DSA #Java #CodingJourney #Consistency #ProblemSolving #TechGrowth
To view or add a comment, sign in
-
-
🚀 Day 18 of #100DaysOfCode Solved LeetCode 334 – Increasing Triplet Subsequence 📈 Today’s problem was all about optimizing from brute force to a smart greedy approach. Instead of checking all triplets, I tracked the smallest and second smallest values while iterating once through the array. 💡 Key Insight: If we find a number greater than both first and second, an increasing triplet exists! 🔍 What I learned: Greedy approach can reduce time complexity drastically Maintaining two variables is enough to detect a triplet Writing clean and efficient O(n) solutions ⚡ Performance: Runtime: 2 ms (Beats 99.28%) Memory: Solid optimization #DSAwithEdSlash #LeetCode #Java #CodingJourney #ProblemSolving
To view or add a comment, sign in
-
-
#Day76 of my second #100DaysOfCode Binary search continues to surprise me with how many variations it has. DSA • Solved Find Peak Element (LeetCode 162) – Brute: check every element → O(n) – Optimal: binary search based on slope comparison → O(log n) • Key idea: if the next element is greater, move right; else move left — a peak is guaranteed • Didn’t need to check all elements, just follow the increasing/decreasing trend Interesting how this doesn’t require a fully sorted array, yet binary search still works. #DSA #BinarySearch #LeetCode #Algorithms #Java #100DaysOfCode #WomenWhoCode #BuildInPublic #LearningInPublic
To view or add a comment, sign in
-
-
🚀 Day 73 of #100DaysOfLeetCode with edSlash Today’s problem: Next Greater Node in Linked List (LeetCode 1019) 🔍 What I learned: How to find the next greater element in a linked list Converting a linked list into an array for easier processing Using a monotonic stack to solve problems efficiently 💡 Key Insight: Instead of brute force (O(n²)), using a stack helps reduce time complexity to O(n) by keeping track of elements in decreasing order. ⚡ Approach: Convert linked list → array Use stack to track indices Find next greater elements 📈 Complexity: Time: O(n) Space: O(n) Every day = 1% better 💪 Let’s keep pushing 🚀 #Day73 #LeetCode #DSA #LinkedList #Stack #Java #CodingJourney #Consistency
To view or add a comment, sign in
-
-
Day 78 of #LeetCode 🚀 Solved: Number of Steps to Reduce a Number to Zero Today’s problem was simple but a great reminder of how important basic logic and loops are. 💡 Key Idea: If number is even → divide by 2 If odd → subtract 1 Repeat until it becomes 0 📌 Focus: Strengthening fundamentals Writing clean and efficient logic Consistency > Complexity 💯 Slowly building problem-solving mindset every day. #Day78 #CodingJourney #Java #DSA #LeetCode #Consistency #FutureDeveloper
To view or add a comment, sign in
-
-
🚀 Day 49 of my #100DaysOfCode Journey Today, I solved the LeetCode problem: Set Mismatch Problem Insight: Given an array containing numbers from 1 to n, one number is duplicated and one number is missing. The goal is to find both of them. Approach: • Used a frequency array to count occurrences of each number • Traversed the input array and updated frequency • Iterated from 1 to n: – If frequency is 2 → duplicate element – If frequency is 0 → missing element • Returned both values as the final result Time Complexity: O(n) Space Complexity: O(n) Key Learnings: • Frequency array is a simple and powerful technique for counting problems • Helps quickly identify missing and repeating elements • Clean and easy-to-understand approach for beginners Takeaway: Sometimes the simplest approach is the most effective. Mastering basic patterns like counting can solve many problems efficiently! #DSA #Java #LeetCode #100DaysOfCode #CodingJourney
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