100 Days of Coding Challenge – Day 3 📌 Problem: Set Matrix Zeroes 🧠 Concepts Used: 2D Arrays, Auxiliary Space, Matrix Traversal 💻 Language: Java 🔍 Platform: LeetCode Solved the Set Matrix Zeroes problem using an auxiliary space approach. I used two boolean arrays to track which rows and columns need to be zeroed, followed by a second pass to update the matrix. This helped keep the logic clear while avoiding unintended overwrites during traversal. 🔗 Code: https://lnkd.in/gVSfeKEi 🔗 Problem: https://lnkd.in/gpQWQuCg #100DaysOfCode #Day3 #Java #DSA #LeetCode #ProblemSolving #CodingJourney #Matrix #Arrays
Java Solution: Set Matrix Zeroes with Auxiliary Space Approach
More Relevant Posts
-
100 Days of Coding Challenge – Day 19 📌 Problem: Merge Sorted Array 💻 Language: Java 🧠 Concept Used: Array Manipulation + Sorting 🔍 Platform: LeetCode Today’s challenge was to merge two sorted arrays into a single sorted array. The result must be stored inside the first array (nums1). Approach: ✔ Copy elements from both arrays into a temporary array ✔ Place the combined elements back into nums1 ✔ Sort the final array to maintain non-decreasing order Time Complexity: O((m+n) log (m+n)) Space Complexity: O(m+n) 🔗 Problem Link: https://lnkd.in/gyFfUaiE 🔗 Code: https://lnkd.in/gA-MrnqG #100DaysOfCode #Day19 #Java #DSA #LeetCode #Arrays #ProblemSolving #CodingJourney
To view or add a comment, sign in
-
-
100 Days of Coding Challenge – Day 16 📌 Problem: Roman to Integer 💻 Language: Java 🧠 Concept Used: HashMap + Conditional Traversal 🔍 Platform: LeetCode Today’s challenge was converting a Roman numeral into its integer representation. Approach: ✔ Stored Roman symbols and values in a HashMap ✔ Traversed the string from left to right ✔ If the current value is smaller than the next → subtract ✔ Otherwise → add Time Complexity: O(n) Space Complexity: O(1) 🔗 Problem Link: https://lnkd.in/g2YTaPrG 🔗 Code: https://lnkd.in/g7e_Y7V7 #100DaysOfCode #Day16 #Java #DSA #LeetCode #Strings #ProblemSolving #CodingJourney
To view or add a comment, sign in
-
-
Day 2/100 – LeetCode Challenge 🚀 Problem: #48 Rotate Image Difficulty: Medium Language: Java Approach: In-Place Rotation using Transpose + Row Reversal Time Complexity: O(n²) Space Complexity: O(1) 🔍 Key Insight: To rotate a matrix 90° clockwise without extra space: 1️⃣ First transpose the matrix (swap across diagonal). 2️⃣ Then reverse each row. This avoids creating a new matrix and satisfies the in-place constraint. 🧠 Solution Brief: Used nested loops to transpose the matrix by swapping arr[i][j] and arr[j][i]. Then reversed each row using two pointers (start and end). Combined both operations inside a rotate() method. Achieved full rotation with constant extra space. 📌 What I Learned: Matrix problems are more about pattern recognition than brute force. Understanding transformations (transpose + reverse) makes complex problems simple. Starting my 100 Days of LeetCode journey today 💪 Consistency > Motivation. #LeetCode #Day2 #100DaysOfCode #Java #DSA #Matrix #ProblemSolving #CodingJourney #MediumProblem
To view or add a comment, sign in
-
-
100 Days of Coding Challenge – Day 9 📌 Problem: 3 Sum 💻 Language: Java 🧠 Concept Used: Sorting + Two Pointer Technique 🔍 Platform: LeetCode Today’s challenge was to find all unique triplets in an array whose sum equals zero — without duplicate combinations. Approach: ✔ Sort the array ✔ Fix one element ✔ Use two pointers to find the other two numbers ✔ Skip duplicates carefully to maintain unique triplets This problem really improved my understanding of pointer movement and edge-case handling. 🔗 Problem Link: https://lnkd.in/gRABQpTt 🔗 Code: https://lnkd.in/ge4qhGAT #100DaysOfCode #Day9 #Java #DSA #LeetCode #TwoPointers #ProblemSolving #CodingJourney
To view or add a comment, sign in
-
-
Day 11/100 Day Coding Challenge Today, I solved the LeetCode problem: Container With Most Water using Java. Here’s a detailed breakdown of my approach and learning: Problem Statement: Given an array of non-negative integers representing heights of vertical lines on a coordinate plane, find two lines that, along with the x-axis, form a container that holds the maximum water. Challenges: A brute-force approach would check all possible pairs of lines (O(n²)), which is inefficient for large arrays. I aimed for an optimized solution using the two-pointer technique. Approach (Two-Pointer Technique): Initialize two pointers: l at the start, r at the end of the array. Compute the current area: curWater = (r - l) * min(height[l], height[r]). Update maximum area found so far. Move the pointer pointing to the shorter line inward: If height[l] < height[r], increment l. Else, decrement r. Repeat until the pointers meet. #100DaysOfCode #Java #LeetCode #TwoPointerTechnique #ProblemSolving #Algorithms #SoftwareEngineering #Day11
To view or add a comment, sign in
-
-
Recently solved "Search a 2D Matrix", and it was a nice reminder that sometimes a problem that looks 2D is actually 1D in disguise. Since each row is sorted and the first element of every row is greater than the last element of the previous row, the matrix can be treated like a single sorted array — making Binary Search the most efficient approach with O(log m×n) time complexity. Small insight, but a good lesson in carefully reading constraints before jumping into coding. 🚀 Problems like this remind me that understanding constraints is more important than memorizing patterns. #LeetCode #DSA #BinarySearch #CodingInterview #ProblemSolving #Java
To view or add a comment, sign in
-
-
Day 44 - LeetCode Journey Solved LeetCode 917: Reverse Only Letters in Java ✅ A clean two-pointer problem that really tests your understanding of string manipulation. The goal was simple: reverse only the letters while keeping all non-letter characters in their original positions. Instead of creating extra data structures, I used two pointers from both ends. If a character is not a letter, we skip it. When both pointers land on letters, we swap them. This continues until the pointers meet. What I liked about this problem is how it teaches you to control movement smartly rather than brute forcing the solution. Key takeaways: • Two-pointer technique for efficient traversal • Handling edge cases (symbols, numbers) • Writing in-place logic without extra space • Clean and readable code ✅ All test cases passed ✅ 100% runtime performance Problems like this improve your thinking for real interview scenarios where optimization matters. #LeetCode #DSA #Java #Strings #TwoPointers #Algorithms #ProblemSolving #CodingJourney #InterviewPrep #Consistency
To view or add a comment, sign in
-
-
Day 32/100 – LeetCode Challenge 🚀 Problem: Regular Expression Matching Approach: Used 2D Dynamic Programming Defined dp[i][j] as whether s[0..i) matches p[0..j) Handled: . → matches any character * → zero or more occurrences of previous character Time Complexity: O(m × n) Space Complexity: O(m × n) Key takeaway: When pattern rules affect previous characters (like *), dynamic programming is often required instead of greedy logic. #LeetCode #100DaysOfCode #DSA #Java #DynamicProgramming #InterviewPrep
To view or add a comment, sign in
-
-
Day 7 | Problem 1 – Sentence Similarity III (LeetCode 1813) Solved Problem 1 by determining whether two sentences can become equal by inserting a group of words at exactly one position. Approach: • Split both sentences into word arrays using split(" ") • Ensured the smaller sentence is used as the base for comparison • Matched common words from the beginning (prefix match) • Matched common words from the end (suffix match) • Checked if prefix + suffix matches covered all words of the smaller sentence This problem strengthened my understanding of: • Two-pointer technique • String manipulation • Logical comparison of sequences Continuing my 15-Day 50+ String DSA Challenge 🚀 #DSA #Java #StringProblems #LeetCode #LearningInPublic #CodingJourney
To view or add a comment, sign in
-
-
100 Days of Coding Challenge – Day 18 📌 Problem: Is Subsequence 💻 Language: Java 🧠 Concept Used: Two Pointer Technique 🔍 Platform: LeetCode Today’s challenge was to determine whether a string s is a subsequence of another string t. A subsequence means the characters appear in the same order, but not necessarily consecutively. Approach: ✔ Use two pointers to traverse both strings ✔ If characters match, move both pointers ✔ Otherwise, move the pointer of the second string ✔ If all characters of s are matched, it is a valid subsequence ✔ Time Complexity: O(n) ✔ Space Complexity: O(1) This problem reinforced how powerful the two-pointer technique can be for efficient string traversal. 🔗 Problem Link: https://lnkd.in/g_43jvhm 🔗 Code: https://lnkd.in/gG_7d2BC #100DaysOfCode #Day18 #Java #DSA #LeetCode #TwoPointers #Strings #ProblemSolving #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