🚀 Day 45 / 180 – DSA with Java 🚀 📘 Topic Covered: Arrays & Two-Pointer Technique 🧩 Problem Solved: Merge Sorted Array Problem: Given two sorted arrays, merge the second array into the first one as a single sorted array. Approach: Started comparing elements from the end of both arrays and filled the first array from the last position backwards. This avoided shifting elements and enabled an efficient in-place merge. Key Learning: ✔️ Using reverse traversal for in-place operations ✔️ Applying two-pointer technique effectively ✔️ Merging sorted data in O(m + n) time If you’re also preparing for DSA, let’s connect and learn together 🤝 #DSA #Java #180DaysOfCode #LearningInPublic #Arrays #ProblemSolving #Consistency
Merging Sorted Arrays with Java Two-Pointer Technique
More Relevant Posts
-
🚀 Day 36 / 180 – DSA with Java 🚀 📘 Topic Covered: Binary Search (Peak Finding) 🧩 Problem Solved: Find Peak Element Problem: Given an array, find a peak element (an element greater than its neighbors) and return its index. Approach: Used Binary Search by comparing the middle element with its neighbors. Based on the increasing or decreasing slope, moved towards the side where a peak must exist, reducing the search space efficiently. Key Learning: ✔️ Applying binary search on unsorted arrays using patterns ✔️ Understanding how slope direction guides decisions ✔️ Solving peak problems in O(log n) time If you’re also preparing for DSA, let’s connect and learn together 🤝 #DSA #Java #180DaysOfCode #LearningInPublic #BinarySearch #ProblemSolving #Consistency
To view or add a comment, sign in
-
-
🚀 Day 46 / 180 – DSA with Java 🚀 📘 Topic Covered: Matrix Manipulation 🧩 Problem Solved: Rotate Image Problem: Given an n x n matrix representing an image, rotate it 90 degrees clockwise in-place. Approach: First transposed the matrix by swapping rows and columns across the diagonal. Then reversed each row to complete the 90-degree clockwise rotation efficiently without extra space. Key Learning: ✔️ Breaking matrix problems into smaller transformations ✔️ Understanding transpose operations ✔️ Solving in-place matrix rotation with O(1) extra space If you’re also preparing for DSA, let’s connect and learn together 🤝 #DSA #Java #180DaysOfCode #LearningInPublic #Matrix #ProblemSolving #Consistency 💙
To view or add a comment, sign in
-
-
🚀 Day 47 / 180 – DSA with Java 🚀 📘 Topic Covered: Matrix Traversal 🧩 Problem Solved: Spiral Matrix Problem: Given a matrix, return all elements in spiral order starting from the top-left corner. Approach: Used four boundaries — top, bottom, left, and right. Traversed layer by layer in four directions (left to right, top to bottom, right to left, bottom to top) while shrinking the boundaries after each pass. Key Learning: ✔️ Managing boundaries in matrix traversal ✔️ Breaking complex movement into clear steps ✔️ Handling edge cases in rectangular matrices If you’re also preparing for DSA, let’s connect and learn together 🤝 #DSA #Java #180DaysOfCode #LearningInPublic #Matrix #ProblemSolving #Consistency
To view or add a comment, sign in
-
-
Just learned something that clicked for me today! 💡 The Frequency Counting Pattern in Java — one of the most used patterns in DSA! The idea is simple: → Use HashMap to count occurrences → Key = element, Value = count → One loop. Done. O(n)! HashMap<Integer, Integer> freq = new HashMap<>(); for (int num : arr) { freq.merge(num, 1, Integer::sum); } This single pattern helped me solve: ✅ Finding duplicates ✅ Most/least frequent element ✅ Character frequency in strings ✅ Two Sum Brute force = O(n²) 😴 HashMap pattern = O(n) 🚀 Still learning and loving every bit of it! Building a Banking System to practice all concepts 🏦 #Java #DSA #LearningInPublic #100DaysOfCode #JavaDeveloper #DataStructures #Programming
To view or add a comment, sign in
-
-
🚀 Day 37 / 180 – DSA with Java 🚀 📘 Topic Covered: Arrays & Two-Pointer Technique 🧩 Problem Solved: Squares of a Sorted Array Problem: Given a sorted array of integers (including negatives), return a new array of the squares of each number, also sorted in non-decreasing order. Approach: Used a two-pointer approach from both ends of the array. Compared squares of elements and filled the result array from the end to maintain sorted order efficiently. Key Learning: ✔️ Handling negative values in sorted arrays ✔️ Using two-pointer technique for optimal solutions ✔️ Avoiding extra sorting to achieve O(n) time complexity If you’re also preparing for DSA, let’s connect and learn together 🤝 #DSA #Java #180DaysOfCode #LearningInPublic #Arrays #ProblemSolving #Consistency
To view or add a comment, sign in
-
-
Day 76 of #100DaysOfLeetCode 💻✅ Solved #33. Search in Rotated Sorted Array problem in Java. Approach: • Applied Binary Search on rotated array • Checked which half is sorted at each step • Reduced search space based on target position Performance: ✓ Runtime: 0 ms (Beats 100.00% submissions) 🚀 ✓ Memory: 43.80 MB (Beats 70.96% submissions) Key Learning: ✓ Mastered searching in rotated sorted arrays ✓ Improved Binary Search decision-making ✓ Learned efficient handling of edge cases Learning one problem every single day 🚀 #Java #LeetCode #DSA #BinarySearch #Arrays #ProblemSolving #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
🚀 DSA Journey — LeetCode Practice 📌 Problem: Maximum Depth of Binary Tree 💻 Language: Java 🔹 Approach: To solve this problem, I used Breadth-First Search (BFS) with a Queue to perform level-order traversal of the binary tree. • Start by adding the root node to the queue • Traverse the tree level by level • For each level, process all nodes currently in the queue • Add left and right children of each node to the queue • Increment the level count after completing each level 📌 Logic Insight: Each iteration of the outer loop represents one level of the tree, which directly helps in calculating the maximum depth. ⏱ Time Complexity: O(n) 🧩 Space Complexity: O(n) (queue storage in worst case) 💡 Key Learning: This problem helped me understand how level-order traversal (BFS) can be used not just for traversal, but also for solving structural problems like finding tree depth efficiently. It also reinforced the importance of queue-based processing in trees. #DSA #Java #LeetCode #BinaryTree #BFS #Queue #CodingJourney #ProblemSolving #LearningInPublic #TreeTraversal
To view or add a comment, sign in
-
-
Day 77 of #100DaysOfLeetCode 💻✅ Solved #153. Find Minimum in Rotated Sorted Array problem in Java. Approach: • Used Binary Search to find minimum element • Compared mid with right to decide direction • Reduced search space until pointers converged Performance: ✓ Runtime: 0 ms (Beats 100.00% submissions) 🚀 ✓ Memory: 43.62 MB (Beats 78.18% submissions) Key Learning: ✓ Strengthened Binary Search on rotated arrays ✓ Learned how to identify unsorted portion efficiently ✓ Improved optimization over linear search Learning one problem every single day 🚀 #Java #LeetCode #DSA #BinarySearch #Arrays #ProblemSolving #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
🚀 Day 38 / 180 – DSA with Java 🚀 📘 Topic Covered: Strings & Two-Pointer Technique 🧩 Problem Solved: Is Subsequence Problem: Given two strings s and t, check whether s is a subsequence of t. Approach: Used two pointers to traverse both strings. Moved the pointer in s only when characters matched, and always moved the pointer in t, ensuring order is maintained. Key Learning: ✔️ Applying two-pointer technique on strings ✔️ Understanding subsequence vs substring ✔️ Writing clean and efficient O(n) solutions If you’re also preparing for DSA, let’s connect and learn together 🤝 #DSA #Java #180DaysOfCode #LearningInPublic #Strings #ProblemSolving #Consistency
To view or add a comment, sign in
-
-
🚀 Java DSA Progress Update I’ve solved 125/310 problems (~40%) as part of my structured Java DSA roadmap. ✔️ Strong in: Arrays, Strings, Linked Lists, Binary Search ⚡ Focusing next on: Heap, Graphs, Dynamic Programming, Sliding Window 📌 Approach: Pattern-based problem solving Time & space analysis Learning from mistakes Re-solving for retention 🎯 Goal: Become interview-ready in 30 days with strong problem-solving fundamentals. Consistent progress > perfection. #Java #DSA #LeetCode #ProblemSolving #SoftwareEngineering
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