🚀 Day 2 / 180 – DSA with Java 🚀 📘 Topic Covered: Arrays & Two-Pointer Technique 🧩 Problem Solved: Move Zeroes Problem: Move all 0s to the end of the array while maintaining the relative order of non-zero elements, without using extra space. Approach: Identified the first zero and used a two-pointer method to swap non-zero elements forward, ensuring an in-place and efficient solution. Key Learning: ✔️ Better understanding of in-place array manipulation ✔️ Practical use of two-pointer logic ✔️ Writing optimized solutions with O(n) time If you’re also preparing for DSA, let’s connect and learn together 🤝 #DSA #Java #180DaysOfCode #LearningInPublic #Arrays #ProblemSolving #Consistency
Move Zeroes to End of Array with Java Two-Pointer Technique
More Relevant Posts
-
🚀 Day 16 / 180 – DSA with Java 🚀 📘 Topic Covered: Arrays & Carry Handling 🧩 Problem Solved: Plus One Problem: Given a number represented as an array of digits, increment the number by one and return the updated array. Approach: Started from the last digit and handled the carry carefully. If the digit was less than 9, incremented it directly. If it was 9, set it to 0 and continued moving left to handle the carry. If all digits were 9, created a new array with an extra leading 1. Key Learning: ✔️ Handling carry propagation in arrays ✔️ Managing edge cases like all 9s ✔️ Thinking about number representation logically 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 4 / 180 – DSA with Java 🚀 📘 Topic Covered: Arrays & Index Manipulation 🧩 Problem Solved: Rearrange Array Elements by Sign Problem: Rearrange the array so that positive and negative numbers appear alternately, while maintaining their original relative order. Approach: Used separate indices for positive and negative positions and placed elements at alternating indices in a new array to achieve the required arrangement efficiently. Key Learning: ✔️ Handling index-based placement in arrays ✔️ Maintaining order while rearranging elements ✔️ Breaking problems into position-mapping logic 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 18 / 180 – DSA with Java 🚀 📘 Topic Covered: Strings & Carry-Based Addition 🧩 Problem Solved: Add Binary Problem: Given two binary strings, return their sum as a binary string. Approach: Traversed both strings from right to left, added corresponding digits along with carry, and built the result step by step. Used a string builder and reversed the final result to get the correct order. Key Learning: ✔️ Handling carry logic in string-based arithmetic ✔️ Simulating manual binary addition programmatically ✔️ Managing different string lengths efficiently 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
-
-
🚀 Day 13 / 180 – DSA with Java 🚀 📘 Topic Covered: Loops & Conditional Logic 🧩 Problem Solved: FizzBuzz Problem: For numbers from 1 to n, return: • “Fizz” if divisible by 3 • “Buzz” if divisible by 5 • “FizzBuzz” if divisible by both • Otherwise, return the number itself Approach: Iterated from 1 to n, checked divisibility conditions, built the appropriate string dynamically, and stored the result in a list. Key Learning: ✔️ Strengthening control flow fundamentals ✔️ Handling multiple conditions cleanly ✔️ Writing simple yet structured logic If you’re also preparing for DSA, let’s connect and learn together 🤝 #DSA #Java #180DaysOfCode #LearningInPublic #ProblemSolving #Consistency
To view or add a comment, sign in
-
-
🚀 Day 14 / 180 – DSA with Java 🚀 📘 Topic Covered: Arrays & Sorted-Rotation Logic 🧩 Problem Solved: Check if Array is Sorted and Rotated Problem: Determine whether a given array is sorted in non-decreasing order and then possibly rotated. Approach: Traversed the array and counted how many times the order decreases (where the current element is smaller than the previous one). If the count of such “break points” is at most one (including the circular check between last and first elements), the array satisfies the condition. Key Learning: ✔️ Understanding sorted array properties ✔️ Handling circular array comparisons ✔️ Solving rotation-based problems efficiently in O(n) time 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 28 / 180 – DSA with Java 🚀 📘 Topic Covered: Strings & Sliding Window 🧩 Problem Solved: Divisor Substrings Problem: Given an integer num and an integer k, find the number of substrings of length k from the digits of num such that the substring value divides num. Approach: Converted the number to a string and used a sliding window of size k to extract substrings. Each substring was converted back to an integer and checked whether it divides the original number. Key Learning: ✔️ Applying sliding window technique on strings ✔️ Converting between numeric and string representations ✔️ Handling edge cases like division by zero 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
-
-
🚀 Day 10 / 180 – DSA with Java 🚀 📘 Topic Covered: Loops & Conditional Logic 🧩 Problem Solved: Sum of Multiples Problem: Given an integer n, calculate the sum of all numbers from 1 to n that are divisible by 3, 5, or 7. Approach: Iterated from 1 to n and checked divisibility conditions. If a number was divisible by 3, 5, or 7, added it to the running sum. Key Learning: ✔️ Strengthening fundamentals with loops and conditions ✔️ Writing clean and readable logic ✔️ Importance of handling multiple conditions efficiently If you’re also preparing for DSA, let’s connect and learn together 🤝 #DSA #Java #180DaysOfCode #LearningInPublic #ProblemSolving #Consistency
To view or add a comment, sign in
-
-
🚀 Day 29 / 180 – DSA with Java 🚀 📘 Topic Covered: Arrays & Two-Pointer Technique 🧩 Problem Solved: Container With Most Water Problem: Given an array where each element represents the height of a vertical line, find two lines that together with the x-axis form a container that holds the maximum amount of water. Approach: Used a two-pointer strategy starting from both ends of the array. Calculated the water area using the shorter height and the distance between pointers, then moved the pointer with the smaller height to try finding a better container. Key Learning: ✔️ Efficient use of two-pointer technique ✔️ Understanding how pointer movement impacts optimization ✔️ Reducing brute-force O(n²) solutions to O(n) 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 22 / 180 – DSA with Java 🚀 📘 Topic Covered: Hashing & Sequence Detection 🧩 Problem Solved: Longest Consecutive Sequence Problem: Given an unsorted array of integers, find the length of the longest consecutive elements sequence in O(n) time. Approach: Stored all elements in a HashSet for O(1) lookups. For each number, only started counting if it was the beginning of a sequence (i.e., the previous number was not present). Then extended the sequence forward to find its length. Key Learning: ✔️ Using HashSet for efficient lookups ✔️ Identifying sequence starting points to avoid redundancy ✔️ Achieving O(n) time complexity for an otherwise sorting-based problem If you’re also preparing for DSA, let’s connect and learn together 🤝 #DSA #Java #180DaysOfCode #LearningInPublic #Hashing #ProblemSolving #Consistency
To view or add a comment, sign in
-
-
🚀 Day 23 / 180 – DSA with Java 🚀 📘 Topic Covered: Linked List Manipulation 🧩 Problem Solved: Delete Node in a Linked List Problem: Given a node in a singly linked list (not the head), delete that node without access to the previous node. Approach: Since the previous node is not accessible, copied the value of the next node into the current node and updated the pointer to skip the next node, effectively deleting it. Key Learning: ✔️ Thinking differently when constraints change ✔️ Understanding pointer manipulation in linked lists ✔️ Solving problems by modifying node structure directly If you’re also preparing for DSA, let’s connect and learn together 🤝 #DSA #Java #180DaysOfCode #LearningInPublic #LinkedList #ProblemSolving #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
Keep it up 👍