Day 89 of #100DaysOfLeetCode 💻✅ Solved #15. 3Sum problem in Java. Approach: • Sorted the array first • Fixed one element and used Two Pointers for the rest • Skipped duplicates to avoid repeated triplets • Adjusted pointers based on sum comparison Performance: ✓ Runtime: 30 ms (Beats 87.77% submissions) ✓ Memory: 59.02 MB (Beats 77.30% submissions) Key Learning: ✓ Mastered Two Pointer technique with sorting ✓ Learned handling duplicates efficiently ✓ Improved problem-solving for combination-based problems Learning one problem every single day 🚀 #Java #LeetCode #DSA #TwoPointers #Arrays #Sorting #ProblemSolving #CodingJourney #100DaysOfCode
Solved 3Sum Problem in Java with Two Pointers Technique
More Relevant Posts
-
Day 63 of #100DaysOfLeetCode 💻✅ Solved #2085. Count Common Words With One Occurrence problem in Java. Approach: • Iterated through each word in the first array • Avoided duplicate checks by ensuring each word is processed only once • Counted occurrences of the current word in both arrays • If the word appears exactly once in both arrays, incremented the result • Returned the final count Performance: ✓ Runtime: 88 ms (Beats 7.45% submissions) ✓ Memory: 46.06 MB (Beats 93.07% submissions) Key Learning: ✓ Practiced handling duplicates and frequency counting ✓ Improved understanding of string comparison in arrays ✓ Learned importance of optimizing nested loop solutions Learning one problem every single day 🚀 #Java #LeetCode #DSA #Strings #Arrays #ProblemSolving #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
Day 65 of #100DaysOfLeetCode 💻✅ Solved “Majority Frequency Group” problem in Java. Approach: • Created a frequency array of size 26 for all characters • Counted occurrences of each character in the string • For each unique frequency, counted how many characters share that frequency • Selected the frequency with the highest group size • In case of tie, chose the higher frequency • Built the result string with characters having the selected frequency Performance: ✓ Runtime: 5 ms (Beats 57.84% submissions) ✓ Memory: 44.51 MB (Beats 72.88% submissions) Key Learning: ✓ Practiced frequency grouping techniques ✓ Learned how to handle tie-breaking conditions ✓ Strengthened logic building with nested loops and conditions Learning one problem every single day 🚀 #Java #LeetCode #DSA #Strings #Hashing #ProblemSolving #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
Day 66 of #100DaysOfLeetCode 💻✅ Solved #3427. Sum of Variable Length Subarrays problem in Java. Approach: • Iterated through each index of the array • Determined the starting index using i - nums[i] • Ensured the start index does not go below 0 • Calculated sum of elements from start to current index i • Added each subarray sum to the total Performance: ✓ Runtime: 1 ms (Beats 99.90% submissions) ✓ Memory: 45.22 MB (Beats 56.30% submissions) Key Learning: ✓ Practiced handling variable-length subarrays ✓ Improved understanding of index-based range calculations ✓ Strengthened nested loop logic for array problems Learning one problem every single day 🚀 #Java #LeetCode #DSA #Arrays #PrefixSum #ProblemSolving #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
Day 62 of #100DaysOfLeetCode 💻✅ Solved #219. Contains Duplicate II problem in Java. Approach: • Used two nested loops to compare elements within range k • For each element, checked next k elements • If any duplicate is found within distance k, returned true • If no such pair exists, returned false Key Learning: ✓ Practiced checking duplicates within a given range ✓ Strengthened understanding of array traversal with conditions ✓ Learned the importance of optimizing nested loop solutions Learning one problem every single day 🚀 #Java #LeetCode #DSA #Arrays #ProblemSolving #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
🚀 I thought I knew Java Arrays… until I actually revised them properly. Most beginners memorize syntax like: int[] arr = new int[5]; But interviews don’t test syntax. They test understanding. Here’s what actually matters: • Why array index starts from 0 • How memory is allocated internally • Why arrays are fixed size • Why O(1) access time makes arrays powerful • When to use Array vs ArrayList If your array basics are weak, Data Structures will feel difficult. Today I revised: ✔ Declaration & Initialization ✔ 2D and Jagged Arrays ✔ Traversal methods ✔ Arrays utility methods Strong fundamentals > Fancy topics. Are your array basics really strong? #Java #DSA #Programming #JavaDeveloper #CodingJourney
To view or add a comment, sign in
-
-
#Day86 of #100DaysOfCode Started learning String manipulation in Java. Covered: * Basic string operations * Using built-in methods like length() and charAt() Practiced problems like: * Reversing a string * Checking palindrome strings * Counting vowels Focused on understanding how to process and manipulate text data. #Java #Strings #100DaysOfCode
To view or add a comment, sign in
-
-
🚀 Day 57 of My Java DSA Journey Today I worked on a classic Dynamic Programming problem: 💡 Subset Sum Problem 🧠 Approach: • Used recursion with memoization • At each step, decided whether to include or exclude an element • Stored intermediate results to optimize performance 🔍 Key Insight: A subset with sum k exists if: We can form k without current element OR We can form k - arr[i] including current element ⚡ What I learned: • DP pattern similar to Knapsack • Importance of proper memoization • Handling boolean DP states 🔥 Complexity: • Time: O(n × k) • Space: O(n × k) 🎯 Takeaway: Many DP problems are variations of a few core patterns. #Day57 #90DaysOfCoding #DSA #DynamicProgramming #Java
To view or add a comment, sign in
-
-
Day 75 of #100DaysOfLeetCode 💻✅ Solved #278. First Bad Version problem in Java. Approach: • Used Binary Search to minimize API calls • Narrowed search space using isBadVersion(mid) • Moved left/right pointers based on condition • Final position gives the first bad version Performance: ✓ Runtime: 16 ms (Beats 10.29% submissions) ✓ Memory: 42.16 MB (Beats 42.59% submissions) Key Learning: ✓ Practiced Binary Search with API-based problems ✓ Improved optimization by reducing unnecessary calls ✓ Strengthened problem-solving using monotonic conditions Learning one problem every single day 🚀 #Java #LeetCode #DSA #BinarySearch #ProblemSolving #CodingJourney #100DaysOfCode
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
-
-
Day 68 of #100DaysOfLeetCode 💻✅ Solved #977. Squares of a Sorted Array problem in Java. Approach: • Traversed the array and squared each element • Used Arrays.sort() to sort the squared values • Returned the sorted array as the result Performance: ✓ Runtime: 10 ms (Beats 37.38% submissions) ✓ Memory: 47.98 MB (Beats 18.78% submissions) Key Learning: ✓ Practiced array transformation and sorting ✓ Learned how squaring affects order in sorted arrays ✓ Understood the importance of optimizing from O(n log n) to O(n) using two pointers Learning one problem every single day 🚀 #Java #LeetCode #DSA #Arrays #Sorting #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