Day: 72/365 📌 LeetCode POTD: Count Submatrices With Equal Frequency of X and Y Medium Key takeaways/Learnings from this problem: 1. The key idea is converting the problem into numbers (like +1 and -1) so equal frequency turns into a sum = 0 problem. 2. 2D prefix sums really help here—you can quickly get submatrix sums without recalculating every time. 3. It’s a nice extension of 1D subarray problems to 2D, so knowing those basics pays off big time. #POTD #365DaysOfCode #DSA #Java #ProblemSolving #LearningInPublic #Consistency 🥷
LeetCode POTD: Counting 2D Submatrices with Equal X and Y Frequencies
More Relevant Posts
-
Day: 71/365 📌 LeetCode POTD: Count Submatrices with Top-Left Element and Sum Less Than k Medium Key takeaways/Learnings from this problem: 1. Prefix sum is the hero here—once you precompute it, submatrix sum becomes instant lookup instead of recomputing every time. 2. Fixing the top-left corner simplifies things a lot, turning a 2D problem into something more manageable. 3. Instead of brute forcing all submatrices, you just expand and check smartly using precomputed sums. #POTD #365DaysOfCode #DSA #Java #ProblemSolving #LearningInPublic #Consistency 🥷
To view or add a comment, sign in
-
-
Solved a problem where we need to check if two strings can be made equal using a special operation. The rule is: you can swap characters only if the distance between their positions is even. So basically, characters at even indices can only swap among themselves, and same for odd indices. Idea: Instead of actually swapping, I just counted characters separately for even and odd positions in both strings. If both match, then it’s possible — otherwise not. Simple concept, but interesting twist! 😊 #LeetCode #DSA #Java #ProblemSolving #CodingJourney
To view or add a comment, sign in
-
-
🚀 Day 48/180 | #180DaysOfCode 📍 LeetCode | 💻 Java Solved: 1534. Count Good Triplets Used a brute-force triple nested loop to check all possible triplets and validate the given conditions using absolute differences. ⏱️ Time Complexity: O(n³) 📦 Space Complexity: O(1) Strengthening understanding of nested loop patterns and condition-based filtering. 💪 Consistency continues 🚀 #DSA #LeetCode #Java #CodingJourney #Consistency
To view or add a comment, sign in
-
-
Day: 75/365 📌 LeetCode POTD: Determine Whether Matrix Can Be Obtained By Rotation Easy Key takeaways/Learnings from this problem: 1. This problem shows that sometimes brute force (trying all 4 rotations) is perfectly fine and clean. 2. Rotating a matrix becomes easy once you remember the transpose + reverse trick. 3. Always compare after each rotation instead of overcomplicating the logic upfront. #POTD #365DaysOfCode #DSA #Java #ProblemSolving #LearningInPublic #Consistency 🥷
To view or add a comment, sign in
-
🚀 Day 52/180 | #180DaysOfCode 📍 LeetCode | 💻 Java Solved: 3174. Clear Digits Used a stack-like approach with StringBuilder to remove the closest non-digit character whenever a digit is encountered. ⏱️ Time Complexity: O(n) 📦 Space Complexity: O(n) Strengthening understanding of string processing and stack-based logic simulation. 💪 Consistency continues 🚀 #DSA #LeetCode #Java #CodingJourney #Consistency
To view or add a comment, sign in
-
-
🚀 Day 54/180 | #180DaysOfCode 📍 LeetCode | 💻 Java Solved: 1656. Design an Ordered Stream Used an array + pointer approach to store values by index and return consecutive chunks by moving a pointer forward whenever elements are available. ⏱️ Time Complexity: O(n) (amortized across all insert calls) 📦 Space Complexity: O(n) Strengthening understanding of design problems and pointer-based simulation techniques. 💪 Consistency continues 🚀 #DSA #LeetCode #Java #CodingJourney #Consistency
To view or add a comment, sign in
-
-
🚀 Day #82/100 – 𝐑𝐞𝐦𝐨𝐯𝐞 𝐄𝐥𝐞𝐦𝐞𝐧𝐭 (LeetCode) Today’s problem was Remove Element — a simple yet important question to understand in-place array manipulation. 🔍 𝐊𝐞𝐲 𝐋𝐞𝐚𝐫𝐧𝐢𝐧𝐠: We don’t need extra space! We can solve this using a two-pointer approach efficiently. 𝐖𝐡𝐲 𝐢𝐭 𝐰𝐨𝐫𝐤𝐬? We overwrite unwanted elements and keep only the valid ones at the beginning of the array. ⚡ 𝐀𝐩𝐩𝐫𝐨𝐚𝐜𝐡: Initialize k = 0 Traverse array: If element ≠ val → place it at index k Increment k Return k (new length) ⏱️ 𝐓𝐢𝐦𝐞 𝐂𝐨𝐦𝐩𝐥𝐞𝐱𝐢𝐭𝐲: O(n) 📦 𝐒𝐩𝐚𝐜𝐞 𝐂𝐨𝐦𝐩𝐥𝐞𝐱𝐢𝐭𝐲: O(1) #Day82 #100DaysOfCode #Java #DSA #LeetCode #TwoPointers #CodingJourney
To view or add a comment, sign in
-
-
🚀 Day 47/180 | #180DaysOfCode 📍 LeetCode | 💻 Java Solved: 448. Find All Numbers Disappeared in an Array Used an in-place marking technique by treating indices as a hash map and marking visited numbers as negative to identify missing elements. ⏱️ Time Complexity: O(n) 📦 Space Complexity: O(1) (excluding output list) Strengthening understanding of array manipulation and in-place hashing tricks. 💪 Consistency continues 🚀 #DSA #LeetCode #Java #CodingJourney #Consistency
To view or add a comment, sign in
-
-
Day: 74/365 📌 LeetCode POTD: Flip Square Submatrix Vertically Easy Key takeaways/Learnings from this problem: 1. This one highlights how matrix manipulation is mostly about correct indexing, not complex logic. 2. Flipping vertically is just swapping rows within the selected submatrix—visualizing it helps a lot. 3. Good reminder to be careful with boundaries when working on submatrices, not the whole grid. #POTD #365DaysOfCode #DSA #Java #ProblemSolving #LearningInPublic #Consistency 🥷
To view or add a comment, sign in
-
Day: 76/365 📌 LeetCode POTD: Maximum Non Negative Product in a Matrix Medium Key takeaways/Learnings from this problem: 1. This problem shows why tracking only max isn’t enough—you need both max and min products because negatives can flip the result. 2. Classic DP twist where each cell depends on top and left, but with sign handling making it interesting. 3. Big takeaway: whenever multiplication + negatives are involved, always think about dual states (min & max). #POTD #365DaysOfCode #DSA #Java #ProblemSolving #LearningInPublic #Consistency 🥷
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