#100DaysOfCode – Day 10 📌 Today’s Problem: LeetCode 152 – Maximum Product Subarray This one was tricky and super interesting! Unlike sum problems, product problems behave differently because of negative numbers and zeros. Key Learning: A negative number can flip the result So we track both: maxSoFar → maximum product till current index minSoFar → minimum product (important for negative flip) Core Idea: If current number is negative → swap maxSoFar and minSoFar Update both values at each step Keep track of global maximum Complexity: Time: O(n) Space: O(1) Takeaway: Tracking both max & min is the key to handling negative numbers in product-based problems. #LeetCode #Java #DSA #CodingJourney #Day10
ANKIT KUMAR’s Post
More Relevant Posts
-
🚀 Day 11/100 — #100DaysOfLeetCode Consistency continues — one problem closer to better problem-solving skills 💻🔥 ✅ Problem Solved: 🔹 LeetCode 1423 — Maximum Points You Can Obtain from Cards 💡 Concepts Used: Sliding Window Technique Complementary Subarray Thinking 🧠 Key Learning: Instead of directly choosing k cards from both ends, I learned to think differently — find the minimum sum subarray of size n - k and subtract it from the total sum. This transformation converts a complex decision problem into a clean sliding window optimization. ⚡ Takeaway: Sometimes optimization comes from changing perspective, not increasing complexity. Continuing the journey 🚀 #100DaysOfLeetCode #LeetCode #DSA #SlidingWindow #Algorithms #Java #ProblemSolving #CodingJourney #LearningInPublic
To view or add a comment, sign in
-
-
#Day82 Of Problem Solving Solved today’s LeetCode Daily Question and got all test cases accepted. Focused on finding the minimum distance between the target element and the given start index. Kept the approach simple—iterated through the array and updated the minimum distance using Math.abs(). Clean logic, efficient, and gets the job done. Performance: Runtime: 1 ms Memory: 45.04 MB Small problems like this are a good reminder that clarity in thinking often beats overcomplication. Staying consistent with daily practice. #LeetCode #Java #ProblemSolving #DSA #CodingJourney #LeetCode #LinkedIn
To view or add a comment, sign in
-
-
🚀 Day 53 of #100DaysOfLeetCode Solved: Next Greater Element (Leetcode 496) Today’s problem was a great reminder of how powerful Monotonic Stack can be for optimization. 🔹 Approach: Used a stack to maintain decreasing elements Mapped each element to its next greater using a HashMap Reduced time complexity from O(n²) → O(n) 🔹 Key Learning: Small mistakes in conditions (like missing a !) can completely break logic. Attention to detail matters just as much as understanding the concept. 🔹 Complexity: Time: O(n + m) Space: O(n) Consistency > Perfection. Showing up daily and improving step by step. #LeetCode #DSA #Java #CodingJourney #ProblemSolving
To view or add a comment, sign in
-
-
Day 57 — small improvements, big impact 🚀 Solved the Maximum Triplet Sum problem today, focusing on writing cleaner and more efficient logic. Used a HashSet to eliminate duplicates and simplified the approach with sorting. It’s interesting how a small optimization can make the solution more robust and elegant. Consistency is starting to pay off — problems feel more approachable, and thinking is getting sharper 💡 Learning to not just solve, but refine solutions is the real progress. On to Day 58 with the same mindset 🔥 #100DaysOfCode #Java #DSA #ProblemSolving #CodingJourney #Consistency #Learning #SoftwareDevelopment
To view or add a comment, sign in
-
-
🚀 Day 87 — LeetCode Practice 🚀 Today’s focus was on ranking logic and nested iteration concepts. ✅ Problem solved today: 🔹 Relative Ranks 💡 Key learnings from today: • Understood how to determine ranks by comparing each element with others • Learned how counting higher scores helps assign positions • Strengthened concepts of nested loops and conditional logic • Explored how to map rankings into strings like Gold Medal, Silver Medal, Bronze Medal • Improved thinking on converting numeric logic into meaningful output 🧠 Approach used: Used a brute-force method where for each score, I counted how many scores are greater than it to determine its rank. ⚡ Time Complexity: O(n²) 📦 Space Complexity: O(n) 📈 Progress: Staying consistent and improving problem-solving step by step! #Day87 #LeetCode #DSA #Java #CodingJourney #Consistency #ProblemSolving #TechGrowth
To view or add a comment, sign in
-
-
🚀 Day 14 of LeetCode Problem Solving Solved today’s problem — LeetCode #34: Find First and Last Position of Element in Sorted Array 💻🔥 ✅ Approach: Binary Search (Twice) ⚡ Time Complexity: O(log n) 📊 Space Complexity: O(1) The task was to find the starting and ending position of a target element in a sorted array. 👉 Instead of linear search, I used Binary Search twice: One to find the first occurrence One to find the last occurrence 💡 Key Idea: Modify binary search slightly to keep searching even after finding the target. 👉 Core Logic: If target found → store index Continue searching left (for first position) Continue searching right (for last position) 💡 Key Learning: Binary Search is not just for finding elements — it can be modified to solve many variations efficiently. Consistency is the key — getting better every day 🚀 #Day14 #LeetCode #DSA #Java #CodingJourney #ProblemSolving #100DaysOfCode
To view or add a comment, sign in
-
-
🚀 Day 33 of #128DaysOfCode 🧩 Problem Insight: The goal was to check whether a given string can be formed by repeating one of its substrings multiple times. 💡 Key Learning: Instead of checking all possible substrings (which can be inefficient), I learned an elegant trick: By concatenating the string with itself and removing the first and last characters, we can determine if the original string exists within it. ⚡ This approach helped me: - Improve my understanding of string patterns - Learn a smart optimization technique - Avoid brute-force solutions 🛠️ Concepts Practiced: - String manipulation - Pattern recognition - Optimized problem-solving approach 📈 Every day I’m getting better at identifying patterns and writing cleaner, more efficient code. #Day33 #128DaysOfCode #Java #DSA #CodingJourney #ProblemSolving #LeetCode
To view or add a comment, sign in
-
-
Day 22/100 — LeetCode Today’s problem: Happy Number 😊 At first, it looked like a simple math problem… but it turned out to be about patterns and repetition. 🔍 What I learned: Break a number into digits using % 10 and / 10 Square each digit and keep adding Repeat the process until: You reach 1 → Happy Number ✅ Or it starts repeating → Not Happy ❌ 🧠 Key Insight: This problem is actually about cycle detection — if a number repeats, it will never reach 1. ⚡ Simple Example: 19 → 82 → 68 → 100 → 1 ✅ 💡 Takeaway: Sometimes problems that look like math are really about loops and patterns. Small steps every day → Big improvement 🚀 #Day22 #100DaysOfCode #LeetCode #Java #DSA #CodingJourney
To view or add a comment, sign in
-
-
60-Day LeetCode Challenge – Day 40 Solved Check if All Characters Have Equal Number of Occurrences on LeetCode. 📌 Approach: Used a frequency array (size 26) to count occurrences of each character, then compared all non-zero frequencies with an expected value. 🧠 Learning: Reinforced frequency counting patterns — a super common technique in string problems. ⚡ Complexity: • Time Complexity: O(n) • Space Complexity: O(1) Starting to see patterns repeat across problems — that’s when things begin to click ⚡ #LeetCode #DSA #Java #Strings #Consistency #ProblemSolving
To view or add a comment, sign in
-
-
🚀 Day 49 of my #100DaysOfCode Journey Today, I solved the LeetCode problem: Set Mismatch Problem Insight: Given an array containing numbers from 1 to n, one number is duplicated and one number is missing. The goal is to find both of them. Approach: • Used a frequency array to count occurrences of each number • Traversed the input array and updated frequency • Iterated from 1 to n: – If frequency is 2 → duplicate element – If frequency is 0 → missing element • Returned both values as the final result Time Complexity: O(n) Space Complexity: O(n) Key Learnings: • Frequency array is a simple and powerful technique for counting problems • Helps quickly identify missing and repeating elements • Clean and easy-to-understand approach for beginners Takeaway: Sometimes the simplest approach is the most effective. Mastering basic patterns like counting can solve many problems efficiently! #DSA #Java #LeetCode #100DaysOfCode #CodingJourney
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