Day 64 of #100DaysOfLeetCode 💻✅ Solved #724. Find Pivot Index problem in Java. Approach: • Calculated the total sum of the array • Maintained a variable left to track left sum • For each index, computed right sum as total - left - nums[i] • Compared left and right sums • If both are equal, returned the index as pivot • Updated left sum by adding current element Performance: ✓ Runtime: 1 ms (Beats 98.68% submissions) 🚀 ✓ Memory: 47.58 MB (Beats 32.00% submissions) Key Learning: ✓ Learned prefix sum technique for efficient calculations ✓ Practiced reducing time complexity from O(n²) to O(n) ✓ Strengthened understanding of array traversal and sum logic Learning one problem every single day 🚀 #Java #LeetCode #DSA #Arrays #PrefixSum #ProblemSolving #CodingJourney #100DaysOfCode
Java LeetCode 724: Find Pivot Index with Prefix Sum
More Relevant Posts
-
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 82 of #100DaysOfLeetCode 💻✅ Solved #11. Container With Most Water problem in Java. Approach: • Used Two Pointer technique • Calculated area using min height and width • Moved pointer with smaller height inward • Tracked maximum area throughout Performance: ✓ Runtime: 5 ms (Beats 83.17% submissions) ✓ Memory: 77.35 MB (Beats 53.65% submissions) Key Learning: ✓ Mastered Two Pointer optimization technique ✓ Learned efficient area calculation strategy ✓ Improved decision-making for pointer movement Learning one problem every single day 🚀 #Java #LeetCode #DSA #TwoPointers #Arrays #ProblemSolving #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
🚀 Solved “Detect Cycles in 2D Grid” (LeetCode 1559) Worked on a classic graph problem and implemented an efficient DFS-based solution in Java. 🔍 Key idea: Treat the grid as an undirected graph and detect cycles by: Traversing only same-character neighbors Tracking the parent cell to avoid false cycles Identifying a cycle when visiting an already visited node (not parent) ⚡ Insight: Using a recursion stack (like in directed graphs) gives wrong results here — parent tracking is the correct approach. ⏱ Complexity: Time: O(m × n) Space: O(m × n) 📌 Also added a clean, documented version to my GitHub with test cases. 🔗 LeetCode: https://lnkd.in/d6CKa-BN 🔗 GitHub: https://lnkd.in/gnEfmGAg #Java #DSA #GraphAlgorithms #LeetCode #CodingJourney
To view or add a comment, sign in
-
-
Day 67 of #100DaysOfLeetCode 💻✅ Solved #91. Decode Ways problem in Java. Approach: • Checked if the input string is empty or starts with '0' • Initialized a DP array to store number of ways to decode up to each index • Used dp[i] = dp[i-1] if single digit is valid (1–9) • Added dp[i-2] if two-digit number is valid (10–26) • Returned dp[n] as the total number of decoding ways Performance: ✓ Runtime: 1 ms (Beats 99.90%) ✓ Memory: 41.5 MB (Beats 55%) Key Learning: ✓ Practiced dynamic programming with strings ✓ Strengthened understanding of single vs double digit constraints ✓ Reinforced how to build DP solutions incrementally Learning one problem every single day 🚀 #Java #LeetCode #DSA #DynamicProgramming #ProblemSolving #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
Day 90 of #100DaysOfLeetCode 💻✅ Solved #42. Trapping Rain Water problem in Java. Approach: • Used Two Pointer technique • Maintained leftMax and rightMax boundaries • Calculated trapped water based on smaller side • Accumulated water while traversing Performance: ✓ Runtime: 0 ms (Beats 100.00% submissions) 🚀 ✓ Memory: 47.70 MB (Beats 72.36% submissions) Key Learning: ✓ Mastered Two Pointer approach for complex problems ✓ Learned optimal water trapping strategy ✓ Improved understanding of boundary-based calculations Learning one problem every single day 🚀 #Java #LeetCode #DSA #TwoPointers #Arrays #ProblemSolving #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
Day 69 of #100DaysOfLeetCode 💻✅ Solved #349. Intersection of Two Arrays problem in Java. Approach: • Iterated through each element of the first array • Checked if the element exists in the second array • Used a temporary array to store intersection elements • Ensured no duplicates by checking already added elements • Copied the result into a final array of correct size Performance: ✓ Runtime: 4 ms (Beats 35.60%) ✓ Memory: 44.41 MB (Beats 96.71%) Key Learning: ✓ Practiced array traversal using nested loops ✓ Learned how to handle duplicates manually ✓ Improved understanding of set-like operations without using extra data structures Learning one problem every single day 🚀 #Java #LeetCode #DSA #Arrays #ProblemSolving #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
Solved LeetCode 17 – Letter Combinations of a Phone Number using backtracking in Java. Approach: Mapped each digit (2–9) to its corresponding characters using a simple array for O(1) access. Then used backtracking to build combinations digit by digit. For every digit: Pick each possible character Append → explore next digit → backtrack Key idea: Treat it like a tree of choices, where each level represents a digit and branches represent possible letters. Key learnings: Backtracking = build → explore → undo StringBuilder helps avoid unnecessary string creation Problems like this are about systematic exploration of choices Time Complexity: O(4^n * n) Space Complexity: O(n) recursion stack + output Consistent DSA practice is strengthening pattern recognition day by day. #Java #DSA #Backtracking #LeetCode #CodingInterview #SoftwareEngineering
To view or add a comment, sign in
-
-
Day 74 of #100DaysOfLeetCode 💻✅ Solved #162. Find Peak Element problem in Java. Approach: • Used Binary Search technique to efficiently find the peak element • Set two pointers, left at start and right at end of the array • Calculated mid index using safe mid formula • Compared nums[mid] with nums[mid + 1] to determine direction • If mid element is smaller, moved search space to right half • Otherwise, moved search space to left half including mid • Continued until left and right pointers converged • Final position (left == right) represents the peak index Performance: ✓ Runtime: 0 ms (Beats 100.00% submissions) 🚀 ✓ Memory: 44.32 MB (Beats 25.49% submissions) Key Learning: ✓ Strengthened understanding of Binary Search on unsorted arrays ✓ Learned how to apply divide-and-conquer beyond traditional searching ✓ Improved intuition for peak finding using neighbor comparison ✓ Practiced optimizing search space instead of linear scanning Learning one problem every single day 🚀 #Java #LeetCode #DSA #BinarySearch #Arrays #ProblemSolving #CodingJourney #100DaysOfCode
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 88 of #100DaysOfLeetCode 💻✅ Solved #56. Merge Intervals problem in Java. Approach: • Sorted intervals based on start time • Compared current interval with last merged interval • Merged overlapping intervals • Added non-overlapping intervals directly Performance: ✓ Runtime: 8 ms (Beats 91.28% submissions) 🚀 ✓ Memory: 49.16 MB (Beats 43.60% submissions) Key Learning: ✓ Learned interval merging technique ✓ Strengthened sorting + traversal logic ✓ Improved handling of overlapping ranges 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