🚀 Coding Challenge: Day 12 Solved Peak Index in a Mountain Array. ⚡ Approach: Used Binary Search instead of linear scan. Compared arr[mid] with arr[mid + 1]: If increasing → move right If decreasing → peak is on left (or mid) This helps directly reach the peak efficiently. ⚡ Time Complexity: ✔ O(log n) ⚡ Space Complexity: ✔ O(1) ⚡ Key Learning: ✔ Binary Search works on patterns, not just sorted arrays ✔ Identify increasing/decreasing trends #DSA #LeetCode #BinarySearch #CPlusPlus #ProblemSolving
Peak Index in Mountain Array with Binary Search
More Relevant Posts
-
Day 11/150 — Neetcode Journey 🚀 Solved: Combination Sum, Combination Sum II, Permutations 💡 Key Insight: Backtracking is about exploring all possibilities while making decisions step by step ⚠️ Challenge: Handling duplicates (especially in Combination Sum II) and understanding when to backtrack correctly 🧠 What I learned: 1. Recursion + decision trees are key to solving these problems 2. Backtracking is more about mindset than syntax 3. Small changes in constraints (like duplicates) change the entire approach This felt less like coding, more like thinking through possibilities. #DataStructures #Algorithms #CodingJourney #DSA #LearningInPublic
To view or add a comment, sign in
-
Day 29 – LeetCode Journey 🚀 Solved Two Sum II – Input Array Is Sorted using the Two Pointer technique, leveraging the sorted nature of the array for an optimal solution. 🔹 Time Complexity: O(n) 🔹 Runtime: 2 ms (Beats 96.37%) 🔹 Memory Usage: 48.58 MB This problem is a great reminder that recognizing patterns (like sorted arrays) can significantly reduce complexity and improve efficiency. Small optimizations, big impact 📈 Staying consistent and sharpening problem-solving skills every day. #LeetCode #DSA #ProblemSolving #CodingJourney #SoftwareEngineering #Consistency #Learning
To view or add a comment, sign in
-
-
🚀 Today’s LeetCode Solve: 3Sum (Problem #15) Today I solved LeetCode 15 – 3Sum, a classic problem that strengthens two-pointer and sorting concepts. 🔍 Problem summary: Given an array, find all unique triplets such that: nums[i] + nums[j] + nums[k] = 0 💡 Approach used: --> First, sort the array --> Fix one element and use two pointers (left, right) for the remaining part --> Skip duplicates to ensure only unique triplets --> Move pointers based on the sum: --> If sum < 0 → move left pointer --> If sum > 0 → move right pointer -->If sum == 0 → store result and move both ⚡ Efficiency: --> Time Complexity: O(n²) --> Space Complexity: O(1) (excluding result list) 📌 Key takeaway: Combining sorting + two-pointer technique is a powerful pattern for many array problems. Challenging problem, but great learning experience 💪 #LeetCode #DSA #3Sum #TwoPointers #ProblemSolving #Algorithms #CodingPractice #LearningInPublic
To view or add a comment, sign in
-
-
LeetCode #51 — N-Queens | Backtracking at Its Best Just solved the classic N-Queens problem — one of the most interesting backtracking challenges that tests logic, recursion, and optimization. Problem Insight:Place n queens on an n × n chessboard so that no two queens attack each other. That means: No same row No same column No same diagonal Approach: Backtracking + Safe Position Checks Place one queen row by row Check if the current position is safe If valid, move to the next row If stuck, backtrack and try another position What I Learned: 1) Backtracking is about trying possibilities efficiently 2) Constraints help prune unnecessary paths 3) Visualizing the board makes recursion easier to understand This problem is a great reminder that patience + recursion can solve even the toughest puzzles. #LeetCode #NQueens #Backtracking #Algorithms #CodingJourney #ProblemSolving #DSA #TechLearning
To view or add a comment, sign in
-
-
Day 57 of solving LeetCode problems. Today’s problem: Remove Invalid Parentheses Not just about coding — this one forces you to think in terms of state exploration, pruning, and optimality. Brute force fails. Smart BFS/DFS thinking wins. Key takeaway: If your approach generates everything, you're already losing. Control the search space or it controls you. 🔺Still showing up. Still sharpening. #LeetCode #DataStructures #Algorithms #CodingJourney #ProblemSolving #SoftwareEngineering #DSA #TechGrowth #Consistency #KeepGrinding #100DaysOfCode #DeveloperLife
To view or add a comment, sign in
-
-
🧠 Day 37/75: Root-to-Leaf Logic In coding, as in life, we often have to explore different paths to see which one leads to our target. Today’s problem, "Path Sum," is a classic exercise in exactly that. Using Recursion, I built a solution that explores every branch of a Binary Tree until it finds a path that hits the exact target sum. It’s a great reminder that even when a structure looks complex, a consistent, step-by-step approach will eventually find the right way through. The Stats: 📅 37 Days of consecutive coding. ⚡ 100% Beats Runtime (0ms) — Performance is key! 🎯 Focus: Tree Traversals & Base Case Logic. The second month of this challenge is providing some of the most interesting logic puzzles yet. Staying focused and keeping the streak alive! 💻🔥 #Consistency #100DaysOfCode #Algorithms #JavaDeveloper #TechGrowth #ProblemSolving #LeetCodeChallenge #TreeTraversal
To view or add a comment, sign in
-
-
🚀 Day 23/60 — Learning Step by Step Today I worked on: 📌 Find All Numbers Disappeared in an Array (LeetCode #448) At first, the problem looked straightforward, but I was unsure how to solve it without using extra space. My initial instinct was to use a hash map, but that would increase space complexity. 💡 The real learning came when I discovered an in-place marking approach: • Using index mapping (value → index) • Marking visited elements by converting values to negative • Identifying missing numbers by checking positive indices • Achieving O(n) time and O(1) extra space This problem helped me understand how we can cleverly use the given array itself as a data structure instead of relying on extra memory. ✨ Key Takeaways: • Always look for in-place solutions before using extra space • Index-based patterns are very powerful in arrays • Constraints often guide you toward the optimal approach • Small observations can lead to big optimizations Still learning, still improving — one step at a time 🚀 Grateful for the guidance and inspiration from Shiv ram Sharma sir. #DSA #LeetCode #Arrays #ProblemSolving #LearningInPublic #Consistency #100DaysOfCode
To view or add a comment, sign in
-
-
🚀 Day 35 | 100 Days of Coding Challenge #DrGViswanathanChallenge 📘 Problem Solved: Next Greater Element I (LeetCode) 🔧 Approach Used (Brute Force): • For each element in nums1, found its index in nums2 • Traversed to the right to find the first greater element • If none found, returned -1 📌 Key Idea: For every element, scan right side to find the next greater value. ⏳ Complexity: Time: O(n × m) Space: O(1) (excluding output) 🧠 Key Learning: Brute force helps build intuition, but this problem can be optimized using a monotonic stack for O(n) performance. 💡 Optimization Insight: Use a stack + hashmap to precompute next greater elements efficiently. 📂 Topics Covered: Arrays, Brute Force, Monotonic Stack #100DaysOfCode #DSA #CPP #LeetCode #CodingJourney #CompetitiveProgramming
To view or add a comment, sign in
-
-
Today I worked on LeetCode problems #46 (Permutations) and #47 (Permutations II). Problem 46 helped reinforce the fundamentals of backtracking — generating all possible permutations by fixing elements one by one and exploring all possibilities. Problem 47 took it a step further by introducing duplicates. It was interesting to handle unique permutations efficiently by avoiding redundant work using techniques like sorting and using a set at each recursion level. Key takeaway: Backtracking is powerful, but handling duplicates correctly is where the real understanding kicks in. Consistent practice like this is helping me strengthen my problem-solving and recursion skills. #leetcode #backtracking #datastructures #algorithms #coding #softwareengineering
To view or add a comment, sign in
-
Day 41: 90-Day Coding Challenge 🚀 Today was about mastering binary search beyond arrays and applying it to answer spaces and structured data. Focused on recognizing when the problem isn’t asking to search data directly, but to efficiently converge on the correct answer using constraints and patterns. Today’s learning highlights: ✅ Using binary search on the answer space for optimization problems with constraints ✅ Leveraging sorted matrix properties for efficient traversal instead of flattening ✅ Applying mathematical pattern building (DP/pointers) for sequence generation A key takeaway was understanding that the same technique can look very different depending on the problem’s structure. Shift perspective. Trust patterns. Refine approach. Day 41 done. On to Day 42. 💻🔥 Anchal Sharma Ikshit .. #90DayCodingChallenge #CodingJourney #ProblemSolving #BinarySearch #Matrices #DynamicProgramming #LearningJourney #Consistency #Growth
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