🚀Day 13 of #120DaysOfCode 📌 Problem: Reverse String(344) 📌 Language: Java 🔍Approach(Two Pointer Technique) 1. Use two pointer . left --> start of the array index . right --> end of the array 2. While left < right: . Swaps[left] and s[right] . Move left forward (left++) . Move right backward (right--) 3. Stop when pointers meet or cross ⏱️ Time and Space Complexity Time Complexity: O(n) Space complexity: O(1) 🔥One problem closer to mastery #120DaysOfCode #Day13 #Java #Array #Leetcode #ProblemSolving #Consistency #LearningEveryday #LearningPublic #Akshay #DSA
Reverse String Java Array Two Pointer Technique
More Relevant Posts
-
Day 68 of #100DaysOfCode 🚀 Today I implemented Pascal’s Triangle using Java. At first glance, it looks like just a pattern problem. But internally, it teaches something powerful — building current state from previous state. 🔹 The first and last elements of every row are always 1 🔹 Every middle element = sum of two elements from the previous row 🔹 This is a classic example of bottom-up thinking Instead of hardcoding values, we dynamically generate each row based on the previous one. This problem strengthened: Nested loop understanding 2D List handling in Java Pattern recognition Thinking in terms of recurrence Small problems. Strong foundations. Consistent progress. On to the next one 💪 #100DaysOfCode #Java #DSA #ProblemSolving #LearningInPublic #dsawithkunal
To view or add a comment, sign in
-
-
🚀 DSA Day 5 / 100 Solved the Two Sum problem on LeetCode using Java. Logic : • Go through the array one number at a time • For each number, check what value is needed to reach the target • Store each number with its index in a HashMap • If the needed value is already stored, we’ve found the answer #DSA #100DaysOfCode #Java #LeetCode #BeginnerDSA #LearningStepByStep #Consistency
To view or add a comment, sign in
-
-
📝 Day 18/30 – LeetCode #153 (Find Minimum in Rotated Sorted Array) | Java I’ve been a bit inconsistent with daily posting lately due to focusing on deeper revision and understanding core patterns rather than just completing problems for the sake of streaks. Coming back with a classic binary search problem. The key insight here was realizing that even after rotation, at least one half of the array remains sorted. By comparing the middle element with the right boundary, we can decide which half contains the minimum and eliminate the other in each step. This approach reduces the search space logarithmically, resulting in an O(log n) solution. Progress isn’t always linear, but learning is still happening. #LeetCode #Java #DSA #BinarySearch #ProblemSolving #LearningInPublic #ConsistencyOverStreaks
To view or add a comment, sign in
-
-
🚀 Day 6 of My 90 Days Java Full Stack Challenge Today, I focused on understanding the theory of String in Java and solved a few basic String problems to build a strong foundation. 📘 What I learned today: What is String in Java Why String is immutable String Constant Pool (SCP) == vs equals() Difference between String, StringBuilder, and StringBuffer How String works internally (memory & performance basics) 🧩 Practice (Basic Level): ✔ Reverse a String ✔ Check Palindrome ✔ Count vowels & consonants ✔ Remove whitespaces 💡 Key takeaway: Before jumping into advanced DSA problems, clarity of concepts matters more than speed. 📅 Plan for tomorrow: 👉 Solve more String DSA problems (intermediate level) and go deeper with hands-on practice. Learning step by step, one day at a time 💪 #Java #StringInJava #90DaysJavaFullStack #DSA #LearningInPublic #Consistency #DeveloperJourney
To view or add a comment, sign in
-
Day 6/30 – LeetCode #242 (Valid Anagram) | Java My initial thought was to sort both strings and compare them, but that adds unnecessary overhead. The more efficient approach was to use a frequency count, since only character occurrences matter here. By using an int[26] array and incrementing/decrementing counts while iterating through both strings, I was able to solve this in O(n) time with O(1) space. This problem reinforced how fixed-size arrays in Java can outperform maps when the character set is known. #LeetCode #Java #DSA #Strings #Hashing #Consistency #LearningInPublic
To view or add a comment, sign in
-
-
🚀Java practice - Day 87 Completed! 👍 Problem: Sum of Squares of Special Elements Language: Java Today’s problem was about identifying special elements in a 1-indexed array. An element is considered special if its index divides the length of the array (n % i == 0). The task was to calculate the sum of the squares of such elements.✨ #Day87 #Java #LeetCode #Arrays #ProblemSolving #DailyCoding #Consistency #100DaysOfCode
To view or add a comment, sign in
-
-
🚀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
To view or add a comment, sign in
-
-
Day 8/30 – LeetCode #14 (Longest Common Prefix) | Java The challenge here wasn’t complexity, but handling edge cases cleanly. My initial thought was to compare characters column by column, but managing bounds made the logic harder to read. Using the first string as a reference prefix and gradually shrinking it with substring() until it matched all other strings simplified the solution. The startsWith() check kept the code readable while maintaining correctness. This problem reinforced how clarity in string manipulation often matters more than clever logic. #LeetCode #Java #DSA #Strings #ProblemSolving #Consistency #LearningInPublic
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
-
-
🚀 #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
-
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