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
100 Days of Coding Challenge Day 32 Subarray Product Less Than K Java
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 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 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
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 23 ✅ — still showing up every day. #100DaysOfCode | LeetCode 151 – Reverse Words in a String Looks easy on the surface. Reverse the words in a string. Simple, right? Not quite. The tricky part? The input can have leading spaces, trailing spaces, AND multiple spaces between words — but the output should be clean with single spaces only. My Java solution: — Trim the input — Split by space — Loop backwards, skip empty strings from the split — Build the result using StringBuilder Final runtime: 5ms | Beats 86.54% 🎯 Honest takeaway: This problem reminded me that edge cases are where real programming lives. It's not just about getting the logic right — it's about thinking about what can go wrong. 23 days in. 77 to go. Let's keep building. 🙌 #LeetCode #DSA #Java #100DaysOfCode #DailyChallenge #CodeNewbie #TechCommunity
To view or add a comment, sign in
-
-
Day 73 of #90DaysDSAChallenge Solved LeetCode 451: Sort Characters By Frequency Learned an important Java design concept today. Problem Overview: The task was to sort characters in a string based on descending frequency. What confused me initially: Why create a separate Freq class instead of just using HashMap and PriorityQueue directly? Key Learning: PriorityQueue stores one complete object at a time. For this problem, each item needs two pieces of data together: Character Frequency Example: Instead of storing: e and 2 separately We package them as: Freq('e', 2) That custom class acts like a container holding both values in one object, so PriorityQueue can compare and sort them correctly. Why this matters: This taught me that custom classes in Java are often not about complexity, they simply bundle related data into one manageable unit. Alternative approach: We can also use Map.Entry<Character, Integer> instead of creating a custom class, but building Freq makes the logic easier to understand while learning. Today’s takeaway: Not every class is for business logic — sometimes it exists just to package data cleanly. #Java #90DaysDSAChallenge #LeetCode #PriorityQueue #HashMap #CodingJourney #ProblemSolving
To view or add a comment, sign in
-
-
💡Day 44 of LeetCode Problem Solved! 🔧 🌟205. Isomorphic Strings🌟 Task : • Given two strings s and t, determine if they are isomorphic. • Two strings s and t are isomorphic if the characters in s can be replaced to get t. • All occurrences of a character must be replaced with another character while preserving the order of characters. • No two characters may map to the same character, but a character may map to itself. Example 1: Input: s = "egg", t = "add" Output: true Explanation: The strings s and t can be made identical by: Mapping 'e' to 'a'. Mapping 'g' to 'd'. Example 2: Input: s = "f11", t = "b23" Output: false Explanation: The strings s and t can not be made identical as '1' needs to be mapped to both '2' and '3'. #LeetCode #Java #DSA #ProblemSolving #Consistency #100DaysOfChallenge #CodingJourney #KeepGrowing
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
-
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