100 Days of Coding Challenge – Day 36 📌 Problem: Maximum Erasure Value 💻 Language: Java 🔍 Platform: LeetCode Approach Used: Sliding Window + HashSet 1. Use two pointers to maintain a window of unique elements 2. Keep a HashSet to track elements in the current window 3. Expand the window by adding new elements and updating the sum 4. If a duplicate is found, shrink the window from the left until it becomes unique 5. Track the maximum sum of the valid window 👉 Key Insight: Maintain a window with only unique elements and maximize its sum Time Complexity: O(n) Space Complexity: O(n) 🔗 Problem Link: https://lnkd.in/e72YnE3y 🔗 Code Link: https://lnkd.in/e66TfVJQ #100DaysOfCode #Day36 #Java #DSA #LeetCode #ProblemSolving #CodingJourney #SlidingWindow #HashSet
Java Maximum Erasure Value LeetCode Challenge Day 36
More Relevant Posts
-
100 Days of Coding Challenge – Day 38 📌 Problem: Max Consecutive Ones III 💻 Language: Java 🔍 Platform: LeetCode Approach Used: Sliding Window (Two Pointers) 1. Use two pointers (left and right) to maintain a window 2. Count the number of zeros in the current window 3. Expand the window by moving right 4. If zeros exceed k, shrink the window from the left 5. Track the maximum window size (right - left + 1) Time Complexity: O(n) Space Complexity: O(1) 🔗 Problem Link: https://lnkd.in/gcryD9Np 🔗 Code Link: https://lnkd.in/g44uWAsX #100DaysOfCode #Day38 #Java #DSA #LeetCode #ProblemSolving #CodingJourney #SlidingWindow #TwoPointers
To view or add a comment, sign in
-
-
100 Days of Coding Challenge – Day 32 📌 Problem: Subarray Product Less Than K 💻 Language: Java 🔍 Platform: LeetCode Approach Used: Sliding Window (Two Pointers) 1. Initialize two pointers (left and right) and a variable to track product 2. Expand the window by moving right and multiply elements 3. If product becomes ≥ k, shrink the window from the left 4. For each valid window, count subarrays using right - left + 1 5. Accumulate the count to get the final answer 👉 Key Insight: If a window is valid, all its subarrays ending at right are also valid Time Complexity: O(n) Space Complexity: O(1) 🔗 Problem Link: https://lnkd.in/gFWbBHeF 🔗 Code Link: https://lnkd.in/gxZF2_JA #100DaysOfCode #Day32 #Java #DSA #LeetCode #ProblemSolving #CodingJourney #SlidingWindow #TwoPointers
To view or add a comment, sign in
-
-
100 Days of Coding Challenge – Day 35 📌 Problem: Longest Repeating Character Replacement 💻 Language: Java 🔍 Platform: LeetCode Approach Used: Sliding Window + Frequency Count 1. Use a sliding window with two pointers (left and right) 2. Maintain a frequency array for characters 3. Track the count of the most frequent character in the window 4. If (window size - max frequency) > k, shrink the window 5. Keep updating the maximum window length 👉 Key Insight: We can replace at most k characters, so window is valid if remaining characters ≤ k Time Complexity: O(n) Space Complexity: O(1) 🔗 Problem Link: https://lnkd.in/gD4WeQJU 🔗 Code Link: https://lnkd.in/gEyEXyXB #100DaysOfCode #Day34 #Java #DSA #LeetCode #ProblemSolving #CodingJourney #SlidingWindow #Strings
To view or add a comment, sign in
-
-
100 Days of Coding Challenge – Day 37 📌 Problem: Longest Repeating Character Replacement 💻 Language: Java 🔍 Platform: LeetCode Approach Used: Sliding Window + Frequency Count 1. Use two pointers (left, right) to maintain a window 2. Keep a frequency array to count characters in the window 3. Track the count of the most frequent character 4. If (window size - max frequency) > k, shrink the window 5. Update the maximum valid window length 👉 Key Insight: Replace at most k characters to make all characters in the window the same Time Complexity: O(n) Space Complexity: O(1) 🔗 Problem Link: https://lnkd.in/gD4WeQJU 🔗 Code Link: https://lnkd.in/g2qqRmfw #100DaysOfCode #Day37 #Java #DSA #LeetCode #ProblemSolving #CodingJourney #SlidingWindow #Strings
To view or add a comment, sign in
-
-
100 Days of Coding Challenge – Day 33 🚀 📌 Problem: Longest Mountain in Array 💻 Language: Java 🔍 Platform: LeetCode Approach Used: Peak Expansion / Two Pointers 1. Traverse the array and identify a peak element (greater than both neighbors) 2. From the peak, expand left while elements are increasing 3. Expand right while elements are decreasing 4. Calculate the length of the mountain (right - left + 1) 5. Track the maximum length across all valid peaks Time Complexity: O(n) Space Complexity: O(1) 🔗 Problem Link: https://lnkd.in/gS3Uzs3t 🔗 Code Link: https://lnkd.in/gG8gq2KU #100DaysOfCode #Day33 #Java #DSA #LeetCode #ProblemSolving #CodingJourney #TwoPointers #Array
To view or add a comment, sign in
-
-
Day 93 - LeetCode Journey Solved LeetCode 9: Palindrome Number in Java ✅ At first glance, it feels like a string problem… but the real challenge is solving it without converting to string. Instead of reversing the whole number, I reversed only half of it and compared both parts. This avoids overflow and keeps it efficient. Smart approach > brute force 💡 Key takeaways: • Handling edge cases (negative numbers, trailing zeroes) • Reversing only half of the number • Avoiding extra space (no string conversion) • Writing optimized mathematical logic ✅ All test cases passed ⚡ O(log n) time and O(1) space Sometimes the best solutions are the simplest ones, just a different way of thinking 🔥 #LeetCode #DSA #Java #Math #ProblemSolving #CodingJourney #InterviewPrep #Consistency #100DaysOfCode
To view or add a comment, sign in
-
-
Day 85 of #100DaysOfLeetCode 💻✅ Solved #76. Minimum Window Substring problem in Java. Approach: * Used Sliding Window with character frequency array * Tracked required characters to match target string * Expanded window and reduced requirement count * Shrunk window to find minimum valid substring Performance: ✓ Runtime: 2 ms (Beats 99.94% submissions) 🚀 ✓ Memory: 45.51 MB (Beats 80.16% submissions) Key Learning: ✓ Mastered advanced Sliding Window technique ✓ Learned optimal substring minimization strategy ✓ Improved handling of variable window constraints Learning one problem every single day 🚀 #Java #LeetCode #DSA #SlidingWindow #Strings #HashMap #ProblemSolving #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
Day 79 of #100DaysOfLeetCode 💻✅ Solved #3. Longest Substring Without Repeating Characters problem in Java. Approach: • Used Sliding Window with HashSet • Expanded window using right pointer • Shrunk window when duplicate found • Tracked maximum substring length Performance: ✓ Runtime: 6 ms (Beats 69.53% submissions) 🚀 ✓ Memory: 46.46 MB (Beats 41.45% submissions) Key Learning: ✓ Strengthened Sliding Window technique ✓ Learned efficient duplicate handling using HashSet ✓ Improved substring optimization skills Learning one problem every single day 🚀 #Java #LeetCode #DSA #SlidingWindow #Strings #ProblemSolving #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
Leetcode Question Number 1848: Minimum Distance to the Target Element. I solved an interesting problem on finding the minimum distance in an array using Java!(Leetcode Daily Challenge) Given an array, a target value, and a starting index, the task is to find the minimum distance between the start index and any occurrence of the target element. Approach I used: 1.Traverse the array 2.Check for target element 3.Calculate distance using Math.abs(start - i) 4.Track minimum using Math.min() #Leetcode #DSA #Leetcode1848 #Java #Leetcodedailychallenge
To view or add a comment, sign in
-
-
Day 91 - LeetCode Journey Solved LeetCode 61: Rotate List in Java ✅ This one is a classic linked list problem where the trick is to avoid brute force rotations. Instead of rotating step by step, I converted the list into a circular linked list, calculated the effective rotations using k % length, and then broke the list at the right position. Simple idea, but powerful optimization. Key takeaways: • Converting list into circular form for easy rotation • Using modulo to reduce unnecessary operations • Finding new tail and head efficiently • Clean pointer manipulation ✅ All test cases passed ⚡ O(n) time and O(1) space Problems like this teach how to think smarter, not harder 💡 #LeetCode #DSA #Java #LinkedList #CodingJourney #ProblemSolving #InterviewPrep #Consistency #100DaysOfCode
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