🚀 #100DaysOfCode | Day 47 🔍 Solved: Find Minimum in Rotated Sorted Array Today I explored another interesting variation of Binary Search. Instead of searching for a target, the goal was to find the minimum element in a rotated sorted array. 💡 Key Insight: By comparing the middle element with the last element, we can determine which half contains the minimum value. Approach: ✔ Used Binary Search to achieve O(log n) time complexity ✔ Compared mid with end to identify the unsorted portion ✔ Narrowed down the search space efficiently What I Learned: This problem helped me understand how binary search can be applied beyond simple searching—especially in rotated and partially sorted arrays. #Java #DSA #LeetCode #BinarySearch #CodingJourney #ProblemSolving #TechSkills
Rotated Sorted Array Minimum Finder via Binary Search
More Relevant Posts
-
🚀 #100DaysOfCode | Day 48 🔍 Solved: Find Peak Element Today I worked on an interesting Binary Search problem where the goal was to find a peak element in an array. 💡Key Insight: By comparing the middle element with its next element, we can determine the direction of the peak. 📌 Approach: ✔ Applied Binary Search for O(log n) efficiency ✔ Compared mid with next element ✔ Moved towards the increasing side to find peak ✔ Reduced search space step by step Why this works: Since adjacent elements are not equal, there will always be at least one peak. By comparing neighboring elements, we can decide the direction and reduce the search space efficiently. 🎯 What I Learned: This problem showed how Binary Search can be used beyond searching—especially for identifying patterns like peaks in arrays. #Java #DSA #LeetCode #BinarySearch #CodingJourney #ProblemSolving #TechSkills 🚀
To view or add a comment, sign in
-
-
📘 DSA Journey — Day 27 Today’s focus: Binary Search on modified arrays. Problem solved: • Search in Rotated Sorted Array (LeetCode 33) Concepts used: • Binary Search • Identifying sorted halves • Conditional search space reduction Key takeaway: This problem extends binary search to a rotated sorted array, where the array is not fully sorted but divided into two sorted parts. At each step, we: • Find the mid element • Check which half (left or right) is sorted • Decide whether the target lies in the sorted half • Eliminate the other half This allows us to still achieve O(log n) time complexity. Continuing to strengthen fundamentals and problem-solving consistency. #DSA #Java #LeetCode #CodingJourney
To view or add a comment, sign in
-
-
#Day77 of my second #100DaysOfCode Finally wrapped up binary search on 1D arrays, now moving to binary search on answers. DSA • Solved Sqrt(x) (LeetCode 69) — finding the integer square root of a number without using built-in functions – Brute: iterate until square exceeds target → O(n) – Optimal: binary search on answer space → O(log n) • Key idea: instead of searching an index, we search for the answer itself • Learned how to narrow down the range based on mid² comparison Nice shift in thinking — binary search feels much more powerful now. #DSA #BinarySearch #LeetCode #Algorithms #Java #100DaysOfCode #WomenWhoCode #BuildInPublic #LearningInPublic
To view or add a comment, sign in
-
-
Day 58/100 | #100DaysOfDSA 🔄🔍 Today’s problem: Search in Rotated Sorted Array A twist on Binary Search with a rotated array. Key idea: Even though the array is rotated, one half is always sorted. Approach: • Use binary search • Find mid element • Check which half is sorted (left or right) • Decide if target lies in the sorted half • Narrow the search accordingly Why it works: At every step, we eliminate half of the search space just like standard binary search. Time Complexity: O(log n) Space Complexity: O(1) Big takeaway: Understanding the structure of the problem helps adapt classic algorithms like binary search. Rotation doesn’t break order — it just shifts it. 🔥 Day 58 done. #100DaysOfCode #LeetCode #DSA #Algorithms #BinarySearch #Arrays #Java #CodingJourney #ProblemSolving #InterviewPrep #TechCommunity
To view or add a comment, sign in
-
-
𝐃𝐚𝐲 𝟓𝟔 – 𝐃𝐒𝐀 𝐉𝐨𝐮𝐫𝐧𝐞𝐲 | 𝐀𝐫𝐫𝐚𝐲𝐬 🚀 Today’s problem focused on finding a peak element using binary search. 𝐏𝐫𝐨𝐛𝐥𝐞𝐦 𝐒𝐨𝐥𝐯𝐞𝐝 • Find Peak Element 𝐀𝐩𝐩𝐫𝐨𝐚𝐜𝐡 • Used binary search instead of linear scan • Compared the middle element with its next element Logic: • If nums[mid] > nums[mid + 1] → peak lies on the left side (including mid) • Else → peak lies on the right side • Continued until left == right 𝐊𝐞𝐲 𝐋𝐞𝐚𝐫𝐧𝐢𝐧𝐠𝐬 • Binary search can be applied on patterns, not just sorted arrays • A peak always exists due to problem constraints • Comparing adjacent elements helps determine direction • Reducing the search space is the key idea 𝐂𝐨𝐦𝐩𝐥𝐞𝐱𝐢𝐭𝐲 • Time: O(log n) • Space: O(1) 𝐓𝐚𝐤𝐞𝐚𝐰𝐚𝐲 Binary search is not about sorted arrays — it’s about eliminating half of the search space using logic. 56 days consistent 🚀 On to Day 57. #DSA #Arrays #BinarySearch #LeetCode #Java #ProblemSolving #DailyCoding #LearningInPublic #SoftwareDeveloper
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 61/100 | #100DaysOfDSA 🧩🚀 Today’s problem: Median of Two Sorted Arrays A classic hard problem with a clever binary search approach. Problem idea: Find the median of two sorted arrays without fully merging them. Key idea: Use binary search on the smaller array to partition both arrays. Why? • We want left half and right half to be balanced • All elements in left ≤ all elements in right How it works: • Pick a cut in array1 • Derive cut in array2 • Check partition validity using boundary elements If valid → we found the median If not → adjust the partition Time Complexity: O(log(min(m, n))) Space Complexity: O(1) Big takeaway: Binary search isn’t just for searching — it can be used to optimize partitions and positions. This one really builds intuition. 🔥 Day 61 done. #100DaysOfCode #LeetCode #DSA #Algorithms #BinarySearch #Java #CodingJourney #ProblemSolving #InterviewPrep #TechCommunity
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
-
-
🚀 Day 84/100 – 𝐒𝐞𝐚𝐫𝐜𝐡 𝐢𝐧 𝐑𝐨𝐭𝐚𝐭𝐞𝐝 𝐒𝐨𝐫𝐭𝐞𝐝 𝐀𝐫𝐫𝐚𝐲 𝐈𝐈 🔍 𝐊𝐞𝐲 𝐋𝐞𝐚𝐫𝐧𝐢𝐧𝐠: Binary search works great on sorted arrays, but duplicates introduce ambiguity — making it harder to decide which half is sorted. 💡 𝐂𝐨𝐫𝐞 𝐈𝐝𝐞𝐚: Use modified binary search Identify the sorted half Handle duplicates by shrinking the search space ⚡ 𝐀𝐩𝐩𝐫𝐨𝐚𝐜𝐡: Find 𝐦𝐢𝐝 If 𝐭𝐚𝐫𝐠𝐞𝐭 𝐟𝐨𝐮𝐧𝐝 → 𝐫𝐞𝐭𝐮𝐫𝐧 𝐭𝐫𝐮𝐞 𝐇𝐚𝐧𝐝𝐥𝐞 𝐝𝐮𝐩𝐥𝐢𝐜𝐚𝐭𝐞𝐬 (𝐥𝐨𝐰++) Check which half is sorted Narrow down search accordingly #Day84 #100DaysOfCode #Java #DSA #LeetCode #BinarySearch #CodingJourney
To view or add a comment, sign in
-
-
#100DaysOfCode – Day 2 Today I worked on a DSA problem based on arrays: Check if an array is sorted and rotated 🔍 Approach: Instead of finding the exact rotation point, I focused on identifying a pattern: In a sorted and rotated array, the order should break at most once. So, I checked how many times an element is greater than the next element while traversing the array in a circular manner. ✔️ If the count of such breaks is 0 or 1 → valid ❌ If it’s more than 1 → not a sorted rotated array 🧠 Key Takeaway: This problem taught me how pattern observation can simplify logic and avoid unnecessary complexity. Sometimes the best solution is not the most obvious one! 📈 Staying consistent and improving step by step 💪 #100DaysOfCode #DSA #DataStructures #Algorithms #Java #CodingJourney #ProblemSolving #LeetCode #Consistency
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