Mastering the Bitonic Array. 🏔️ Today's win: Finding the maximum element in an array using an optimized O(log n) Binary Search. The trick was handling the boundary conditions (checking mid == 0 or mid == n-1) to ensure the comparisons don't throw an index out of bounds. Stats: ✅ 1111 Test Cases ✅ 0.15s Runtime ✅ Total Score: 10 Seeing that green "Problem Solved Successfully" never gets old. #CodingLogic #Java #BinarySearch #BackendDevelopment #GeeksforGeeks
Optimized Binary Search for Maximum Element in Array
More Relevant Posts
-
🚀 Day 64/100 Today’s problem: Find all strings that are substrings of another word 🧠 What I learned: - How to compare strings using nested loops - Using ".contains()" to check substrings efficiently - Importance of breaking early to optimize performance - Strengthening problem-solving with brute-force approach 💡 Key Insight: Sometimes simple solutions (O(n²)) are enough when constraints are small. No need to overcomplicate! 🔁 Consistency > Perfection #Day64 #DSA #Java #CodingJourney #Consistency #KeepLearning #100DaysOfCode
To view or add a comment, sign in
-
-
Day 78 – Next Greater Node in Linked List Solved a problem to find the next greater value for each node in a linked list by combining linked list traversal with a monotonic stack approach. Key Learnings: Converted a linked list into an array to enable index-based processing Applied the monotonic stack technique to efficiently find next greater elements #DSA #Java #LinkedList #Stack #ProblemSolving #CodingPractice
To view or add a comment, sign in
-
-
Day 64 - Intersection of Two Linked Lists Solved by using a two-pointer technique to find the intersection node of two linked lists. Instead of calculating lengths, both pointers traverse both lists to align automatically. Time Complexity: O(n + m) Space Complexity: O(1) #Day64 #LeetCode #Java #LinkedList #DSA #ProblemSolving #CodingJourney
To view or add a comment, sign in
-
-
🚀 Day 67 of #LeetCode Challenge ✅ Problem Solved: Check If Two String Arrays are Equivalent 💡 What I learned today: • Learned how to compare two string arrays without joining them • Understood how to traverse multiple strings using pointers • Improved handling of indices across arrays and strings • Realized the importance of edge cases to avoid runtime errors 🧠 Approach: • Used four pointers to track positions in both arrays and strings • Compared characters one by one • Moved to the next string when current string ends • Ensured both arrays are fully traversed at the end 📊 Key Takeaway: Efficient solutions avoid extra space — comparing character by character is better than building new strings 🔥 Consistency + small improvements every day = big progress #Day67 #LeetCode #CodingJourney #DSA #Java #ProblemSolving #Consistency
To view or add a comment, sign in
-
-
LeetCode — Problem 189 | Day 3 💡 Problem: Rotate Array Given an array, rotate it to the right by k steps. 🧠 My Approach: - Used reverse technique for in-place rotation - First reversed the entire array - Then reversed first k elements - Finally reversed remaining elements - Handled k using k = k % n This problem gave a good understanding of: ✔️ Array manipulation ✔️ In-place optimization (O(1) space) ✔️ Reverse logic #LeetCode #DSA #Java #CodingJourney
To view or add a comment, sign in
-
-
🚀 𝐃𝐚𝐲 94/100 ✅ 𝐏𝐫𝐨𝐛𝐥𝐞𝐦: 𝐑𝐞𝐩𝐞𝐚𝐭𝐞𝐝 𝐒𝐮𝐛𝐬𝐭𝐫𝐢𝐧𝐠 𝐏𝐚𝐭𝐭𝐞𝐫𝐧 Today’s problem was about checking whether a string can be formed by repeating one of its substrings multiple times. 💡 𝐊𝐞𝐲 𝐋𝐞𝐚𝐫𝐧𝐢𝐧𝐠𝐬: Try all possible substring lengths up to n/2 Only consider lengths that divide the string completely Build and compare repeated string with original Time Complexity: O(n²) in worst case 𝐀𝐩𝐩𝐫𝐨𝐚𝐜𝐡: Iterate over possible substring sizes If length divides string → repeat substring Compare with original string If match found → return true #Day94 #100DaysOfCode #LeetCode #Java #DSA #CodingJourney #ProblemSolving
To view or add a comment, sign in
-
-
🚀 Day 92/100 ✅ 𝐏𝐫𝐨𝐛𝐥𝐞𝐦: 𝐓𝐡𝐢𝐫𝐝 𝐌𝐚𝐱𝐢𝐦𝐮𝐦 𝐍𝐮𝐦𝐛𝐞𝐫 Today’s problem was about finding the third distinct maximum number in an array. If it doesn’t exist, we return the maximum number instead. 💡 𝐊𝐞𝐲 𝐋𝐞𝐚𝐫𝐧𝐢𝐧𝐠𝐬: Maintain three variables to track top 3 distinct values Handle 𝐝𝐮𝐩𝐥𝐢𝐜𝐚𝐭𝐞𝐬carefully Use 𝐋𝐨𝐧𝐠.𝐌𝐈𝐍_𝐕𝐀𝐋𝐔𝐄 to avoid edge case issues Single pass solution → 𝐎(𝐧) 𝐭𝐢𝐦𝐞 𝐜𝐨𝐦𝐩𝐥𝐞𝐱𝐢𝐭𝐲 𝐀𝐩𝐩𝐫𝐨𝐚𝐜𝐡: Instead of sorting, we efficiently track max1, max2, and max3 while iterating through the array. This improves performance and avoids unnecessary computations. #Day92 #100DaysOfCode #LeetCode #Java #DSA #CodingJourney #ProblemSolving #TechGrowth
To view or add a comment, sign in
-
-
🚀 Day 35 of my #100DaysOfCode Journey Today, I solved the LeetCode problem: Valid Anagram Problem Insight: Given two strings, check if one is an anagram of the other. Approach: • First, check if the strings have the same length; if not, return false • Convert both strings to character arrays • Sort both arrays • Compare the sorted arrays — if equal, the strings are anagrams Time Complexity: • O(n log n) — due to sorting the arrays Space Complexity: • O(n) — for the character arrays Key Learnings: • Sorting is a simple and effective way to compare character compositions • Edge cases like different lengths should be handled first • Breaking the problem into small steps makes it easy to reason about Takeaway: Sometimes, sorting can reduce a seemingly complex problem into a simple comparison. #DSA #Java #LeetCode #100DaysOfCode #CodingJourney #ProblemSolving #Strings
To view or add a comment, sign in
-
-
Day 81 - Balanced Binary Tree Checked whether a binary tree is height-balanced using a bottom-up approach. Approach: • Recursively compute height of left and right subtrees • If height difference > 1 → not balanced • Use -1 as a signal to stop early Time Complexity: O(n) Space Complexity: O(h) #Day81 #LeetCode #BinaryTree #DSA #Java #CodingJourney #ProblemSolving
To view or add a comment, sign in
-
-
Day 88 - Merge Two Binary Trees Combined two binary trees by summing overlapping nodes. Approach: • If both nodes exist → create new node with sum • If one node is null → use the other node • Recursively merge left and right subtrees Time Complexity: O(n) Space Complexity: O(h) #Day88 #LeetCode #BinaryTree #Recursion #DSA #Java #CodingJourney
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