🚀Day 14 of #120DaysOfCode 📌 Problem: Matrix Reshape(566) 📌 Language: Java 🔍Approach 1. Check if Reshape is possible 2. Traverse the original matrix in row order 3. Mapping logic ⏱️ Time and Space Complexity Time Complexity: O(m x n) Space complexity: O(r x c) 🔥One problem closer to mastery #120DaysOfCode #Day14 #Java #Array #Leetcode #ProblemSolving #Consistency #LearningEveryday #LearningPublic #DSA
Java Matrix Reshape Problem Solution
More Relevant Posts
-
🚀Day 20 of #120DaysOfCode 📌 Problem: Reverse Integer(7) 📌 Language: Java Algorithm: 1. Initialize rev = 0 2. While x != 0 . Extract digit . Check overflow . Update rev 3. Return rev ⏱️ Time and Space Complexity Time Complexity: O(logn) Space complexity: O(1) 🔥One problem closer to mastery #120DaysOfCode #Day20 #Java #Array #Leetcode #ProblemSolving #Consistency #LearningEveryday #LearningPublic #DSA
To view or add a comment, sign in
-
-
📝 Day 19/30 – LeetCode #33 (Search in Rotated Sorted Array) | Java This problem combines binary search with array rotation, making it more about logic than syntax. The main challenge was identifying which half of the array is sorted at every step and deciding whether the target lies within that range. By comparing boundary values and narrowing the search space accordingly, the problem can be solved efficiently in O(log n) time. This reinforced how adaptable binary search becomes when combined with careful condition checks. Another reminder that mastering patterns is far more important than memorizing solutions. #LeetCode #Java #DSA #BinarySearch #Arrays #ProblemSolving #LearningInPublic
To view or add a comment, sign in
-
-
🚀 Day 2 | Problem 1 of my 15-Day 50+ String DSA Challenge Problem: Find Length of a String (without using length()) Today I practised a basic but important string problem in Java and focused on understanding different looping approaches. Key learnings: • Calculated string length without using built-in methods • Understood the difference between `for` loop and `for-each` loop • Learned when index-based iteration is needed and when simple traversal is enough Strengthening fundamentals step by step 💪 #DSA #Java #StringProblems #LearningInPublic #CodingJourney
To view or add a comment, sign in
-
-
DSA journey 🚀 📌 LeetCode #509 – Fibonacci Number 💻 Language: Java 🔹 Approach: - Handle base cases (n == 0 and n == 1) - Use an iterative approach instead of recursion - Build the Fibonacci sequence using variables ⏱ Time Complexity: O(n) 🧩 Space Complexity: O(1) Consistency over perfection 💯 #DSA #Java #LeetCode #ProblemSolving #LearningInPublic
To view or add a comment, sign in
-
-
🚀 #100DaysOfCode | Day 35 📌 LeetCode : Minimum Depth of Binary Tree Today I solved the Minimum Depth of Binary Tree problem using Java. The goal was to find the shortest path from the root node to the nearest leaf node. I applied a recursive approach while carefully handling edge cases where one subtree is null. Instead of directly taking the minimum of both sides, I ensured the solution correctly skips null paths to avoid incorrect depth calculations. 📌 Key takeaways: 🔹 Understood the difference between minimum and maximum depth logic 🔹 Learned the importance of handling null child nodes 🔹 Strengthened recursion and tree traversal concepts 🔹 Improved problem-solving accuracy in edge cases This problem helped me think more clearly about tree structures and reinforced the importance of precise base conditions in recursion. #Java #LeetCode #DSA #ProblemSolving #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
DSA journey 🚀 📌 LeetCode #167 – Two Sum II (Input Array Is Sorted) 💻 Language: Java 🔹 Approach (Two Pointer Technique): Initialize two pointers at the start and end of the sorted array Calculate the sum of both pointers If the sum equals the target → return 1-based indices If the sum is smaller than the target → move the start pointer forward If the sum is greater than the target → move the end pointer backward Efficient use of the sorted property 💡 ⏱ Time Complexity: O(n) 🧩 Space Complexity: O(1) Step-by-step clarity before optimization ✨ Consistency over perfection 💯 #DSA #Java #LeetCode #ProblemSolving #LearningInPublic
To view or add a comment, sign in
-
-
🚀 Week 2 of Java DSA – Arrays Deep Dive This week, I went deeper into Arrays using Java and focused on improving problem-solving skills through medium-level DSA problems. 🔹 What I worked on: • Arrays in depth (indexing, patterns, edge cases) • Optimizing solutions using better logic • Solving medium-level array problems • Improving time complexity awareness while coding 🔹 Key learnings: • Small optimizations can make a big difference • Handling edge cases is as important as core logic • Writing efficient array-based solutions requires clarity, not speed Continuing the journey with more challenging problems ahead 🚀 #Java #DSA #Arrays #ProblemSolving #LearningInPublic #Consistency #LeetCode
To view or add a comment, sign in
-
-
DSA journey 🚀 📌 LeetCode #268 – Missing Number 💻 Language: Java 🔹 Approach: Use the sum of first n natural numbers formula Calculate the expected sum: n * (n + 1) / 2 Find the actual sum of array elements The difference gives the missing number 🔹 Formula Used: Missing Number = Expected Sum − Actual Sum ⏱ Time Complexity: O(n) 🧩 Space Complexity: O(1) Simple math, clean logic ✨ Consistency over perfection 💯 #DSA #Java #LeetCode #ProblemSolving #LearningInPublic
To view or add a comment, sign in
-
-
DSA journey 🚀 📌 LeetCode #1 – Two Sum 💻 Language: Java 🔹 Approach: Use two nested loops to check all possible pairs Compare the sum of each pair with the target Return indices once the matching pair is found ⏱ Time Complexity: O(n²) 🧩 Space Complexity: O(1) Consistency over perfection 💯 #DSA #Java #LeetCode #ProblemSolving #LearningInPublic #DSAWithedSlash
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