Day 24/50 – LeetCode Solved the Reverse String problem using the two-pointer approach. The solution involves swapping characters from both ends of the array and moving inward until the pointers meet. This ensures an in-place reversal with O(1) extra space and O(n) time complexity. A straightforward problem that reinforces fundamental concepts. #LeetCode #50DaysOfCode #Java #DataStructures
Reversing Strings with Two Pointers in Java
More Relevant Posts
-
Day 50 – Decode String Worked on decoding encoded strings with patterns like k[encoded_string], including handling nested structures using stacks. Key Learnings: Learned how to use stacks to manage nested patterns effectively Understood how to process numbers, brackets, and characters step by step #DSA #Java #Stack #Strings #ProblemSolving #CodingPractice
To view or add a comment, sign in
-
-
🚀 Day 35 of my #100DaysOfCode Journey Today, I solved the LeetCode problem: Valid Anagram Problem Insight: Given two strings, check if one is an anagram of the other. Approach: • First, check if the strings have the same length; if not, return false • Convert both strings to character arrays • Sort both arrays • Compare the sorted arrays — if equal, the strings are anagrams Time Complexity: • O(n log n) — due to sorting the arrays Space Complexity: • O(n) — for the character arrays Key Learnings: • Sorting is a simple and effective way to compare character compositions • Edge cases like different lengths should be handled first • Breaking the problem into small steps makes it easy to reason about Takeaway: Sometimes, sorting can reduce a seemingly complex problem into a simple comparison. #DSA #Java #LeetCode #100DaysOfCode #CodingJourney #ProblemSolving #Strings
To view or add a comment, sign in
-
-
🚀 Day 8/30 — LeetCode Challenge Solved "Swap Nodes in Pairs" on LeetCode using Java. This problem focuses on "rearranging node connections", not just swapping values — making pointer handling critical. Used a dummy node approach to simplify edge cases and ensure smooth pair-wise swapping. ✅ Key takeaway: Linked list problems are less about logic and more about **precise pointer management** — one wrong link can break the entire structure. #LeetCode #Java #LinkedList #DataStructures #ProblemSolving #Consistency
To view or add a comment, sign in
-
-
🚀 Day 4 / 100: LeetCode Challenge Today’s problem: Longest Common Prefix ✅ Learned how sorting an array can simplify finding common prefixes. ✅ Compared the first and last strings after sorting to efficiently determine the prefix. ✅ Key takeaway: sometimes a small trick like sorting can reduce complexity and simplify logic. #100DaysOfCode #Java #LeetCode #CodingChallenge #Day4
To view or add a comment, sign in
-
-
Day 64 - Intersection of Two Linked Lists Solved by using a two-pointer technique to find the intersection node of two linked lists. Instead of calculating lengths, both pointers traverse both lists to align automatically. Time Complexity: O(n + m) Space Complexity: O(1) #Day64 #LeetCode #Java #LinkedList #DSA #ProblemSolving #CodingJourney
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
-
-
#Day85 of #100DaysOfCode Focused on practicing array-based problems with an emphasis on logic and efficiency. Worked on: * Moving zeros to the end of an array * Checking if an array is a palindrome * Calculating the sum of even elements #Java #Arrays #100DaysOfCode
To view or add a comment, sign in
-
-
🚀100 Days of Code Day-26 LeetCode Practice – Remove Duplicates from Sorted Array Solved a classic problem using the Two Pointer Technique 💡 📌 Problem: Given a sorted array, remove duplicates in-place and return the number of unique elements. 🔍 Key Idea: Since the array is sorted, duplicates are adjacent. Using two pointers helps efficiently overwrite duplicates without extra space. ⚡ Complexity: Time → O(n) Space → O(1) 💻 Clean and optimized approach makes this problem a great example of in-place array manipulation! #LeetCode #Java #DataStructures #CodingPractice #ProblemSolving #100DaysOfCode
To view or add a comment, sign in
-
-
Day 59 — LeetCode Progress (Java) Problem: Count the Number of Consistent Strings Required: Given a string allowed and an array of strings words, return the number of consistent strings (strings that contain only characters from allowed). Idea: Use a HashSet for fast lookup to check whether each character in a word is allowed. Approach: Store all characters of allowed in a HashSet. Iterate through each word: Check every character in the word If any character is not in the set, the word is invalid Count all valid (consistent) words. Time Complexity: O(n × m) Space Complexity: O(1) #LeetCode #DSA #Java #HashSet #Strings #Algorithms #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
💻 Day 35 of #LeetCode Journey 🔥 Solved: 19. Remove Nth Node From End of List Today’s problem was all about mastering Linked Lists and understanding the power of the Two Pointer technique. 🔍 Key Idea: Instead of calculating the length, I used a smart approach with fast and slow pointers. Move the fast pointer n steps ahead Then move both pointers together This helps locate the node to remove in a single pass ⚡ Why this approach? Efficient: O(n) time complexity No extra space required Clean and optimal solution 🧠 What I learned: Using a dummy node simplifies edge cases (like removing the head) Two-pointer technique is very powerful in linked list problems 📌 Problem Link: https://lnkd.in/gxXDR-YV #Java #DataStructures #LinkedList #CodingJourney #100DaysOfCode #LeetCode #ProblemSolving
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