Day 17/100 – #100DaysOfCode 🚀 | #Java #DSA #LeetCode ✅ Problem Solved: Add Two Numbers 🔎 Task: You’re given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each node contains a single digit. Return the sum as a linked list. 💡 Approach Used: Traverse both lists simultaneously. Keep track of carry while adding digits. Create a new linked list to store the result. 🧠 Key Concepts: Linked List, Iteration, Carry Handling ⚙️ Time Complexity: O(max(m, n)) 📦 Space Complexity: O(max(m, n)) ✨ Today’s takeaway: Breaking complex problems into smaller iterative steps makes implementation smoother 🚀 #Java #LeetCode #DSA #ProblemSolving #CodingChallenge #ProgrammingJourney #100DaysOfCode
Solved: Add Two Numbers with Java and LeetCode
More Relevant Posts
-
Day 24/100 – #100DaysOfCode 🚀 | #Java #LeetCode #DSA #LinkedList ✅ Problem Solved: Linked List Cycle II 🔎 Task: Given the head of a linked list, return the node where the cycle begins. If there is no cycle, return null. 💡 Approach Used: Used Floyd’s Tortoise and Hare Algorithm to detect the cycle. Once a meeting point is found, moved one pointer to head and kept the other at the meeting point — both move one step at a time until they meet again (start of cycle). 🧠 Key Concepts: Two Pointers, Linked List Traversal, Cycle Detection ⚙️ Time Complexity: O(n) 📦 Space Complexity: O(1) ✨ Today’s takeaway: Understanding the mathematical intuition behind pointer movement makes linked list cycle problems easy to visualize and solve 🔄 #Java #LeetCode #DSA #ProblemSolving #CodingChallenge #100DaysOfCode
To view or add a comment, sign in
-
-
🚀Day 29/100 - Problem of the day :- Minimum Number of Increments on Subarrays to Form a Target Array. 🎯 Goal: Solve the “Minimum Number of Increments on Subarrays to Form a Target Array” problem efficiently on LeetCode. 💡 Core Idea: The key observation is that we only need to add operations when the current element is greater than the previous one. So, the total operations = target[0] + sum(max(target[i] - target[i-1], 0)). This approach ensures we only count necessary increments, avoiding redundant steps. 🎯 Key Takeaway: By focusing on the difference between consecutive elements, we transform a complex problem into a simple linear pass — achieving both clarity and top performance. ✅ Passed all 129 test cases 🚀 Runtime beats 100% of Java submissions 💾 Space Complexity: O(1) — constant extra space used. ⏱ Time Complexity: O(n) — single pass through the array. #Java #DSA #ProblemSolving #Day29 #Leetcode #CodingJourney #100DaysChallenge
To view or add a comment, sign in
-
-
🚀 𝐃𝐚𝐲 9 𝐨𝐟 𝐦𝐲 #100𝐃𝐚𝐲𝐬𝐎𝐟𝐃𝐒𝐀 𝐉𝐨𝐮𝐫𝐧𝐞𝐲 𝐏𝐫𝐨𝐛𝐥𝐞𝐦𝐬 𝐒𝐨𝐥𝐯𝐞𝐝 𝐓𝐨𝐝𝐚𝐲 : 🔥 1️⃣ Leetcode (Medium) – Product of Array Except Self 💡 Key Idea: Instead of using division, use Prefix and Suffix Products. Prefix → product of all elements before the current index Suffix → product of all elements after the current index Multiply both to get the result for each element. 🧾 Time Complexity: O(n) ⚙️ Space Complexity: O(1) #DSA #Java #100DaysOfCode #ProblemSolving #LearningInPublic #SortingAlgorithms #CodingJourney
To view or add a comment, sign in
-
-
Day 25/100 – #100DaysOfCode 🚀 | #Java #LeetCode #DSA #BinarySearch ✅ Problem Solved: Find Minimum in Rotated Sorted Array II 🔎 Task: Given a rotated sorted array (which may contain duplicates), find the minimum element. 💡 Approach Used: Used Modified Binary Search to handle duplicates. Carefully adjusted search boundaries when nums[mid] == nums[right] to avoid missing the minimum. Ensured O(log n) in most cases, degrading gracefully to O(n) for worst-case duplicates. 🧠 Key Concepts: Binary Search, Array Rotation, Edge Case Handling ⚙️ Time Complexity: O(log n) average 📦 Space Complexity: O(1) ✨ Today’s takeaway: Binary search isn’t just about finding — it’s about knowing when to shrink the search space smartly ⚔️ #Java #LeetCode #DSA #ProblemSolving #CodingChallenge #100DaysOfCode #BinarySearch
To view or add a comment, sign in
-
-
💡 Strengthening Problem-Solving Skills with LeetCode (Java) I recently practiced a few algorithmic challenges focused on optimising time and space complexity using greedy strategies and iterative logic: 🔹 Best Time to Buy and Sell Stock (I) Implemented a single-pass solution to track minimum prices and calculate the maximum achievable profit. Approach: Greedy Time Complexity: O(n) 🔹 Best Time to Buy and Sell Stock (II) Designed a solution to capture all profitable opportunities through consecutive transactions. Approach: Greedy Time Complexity: O(n) 🔹 Jump Game Developed an efficient method to verify reachability of the last index by dynamically tracking the farthest reachable position. Approach: Greedy Time Complexity: O(n) Each of these problems reinforced the importance of clarity in logic design and the efficiency that comes with the right algorithmic approach. #LeetCode #Java #ProblemSolving #DSA #Coding #Algorithms #SoftwareEngineering
To view or add a comment, sign in
-
Day 20/100 – #100DaysOfCode 🚀 | #Java #DSA #LeetCode #BinarySearch ✅ Problem Solved: Median of Two Sorted Arrays 🔎 Task: Given two sorted arrays nums1 and nums2 of size m and n, return the median of the two sorted arrays. The overall runtime complexity must be O(log (m + n)). 💡 Approach Used: Applied Binary Search on the smaller array. Partitioned both arrays so that all elements on the left side are smaller than those on the right. Calculated median based on partition boundaries. 🧠 Key Concepts: Binary Search, Divide & Conquer, Edge Case Handling ⚙️ Time Complexity: O(log(min(m, n))) 📦 Space Complexity: O(1) ✨ Today’s takeaway: Binary search isn’t just for searching — it’s a powerful tool for optimization problems too! ⚡ #Java #LeetCode #DSA #BinarySearch #ProblemSolving #ProgrammingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
#100DaysOfCode – Day 80 Reverse Linked List Problem: Given the head of a singly linked list, reverse the list and return the reversed version. Example: Input: [1, 2, 3, 4, 5] Output: [5, 4, 3, 2, 1] My Approach: Used an iterative method to reverse the list efficiently by manipulating pointers. Initialized three pointers prev, temp, and front. Iteratively reversed each node’s direction until the end of the list was reached. Returned prev as the new head of the reversed list. Time Complexity: O(N) Space Complexity: O(1) Reversing a linked list might look tricky at first, but once you understand pointer manipulation it’s pure logic and flow. #takeUforward #100DaysOfCode #DSA #Java #ProblemSolving #LeetCode #LinkedList #Pointers #CodeNewbie
To view or add a comment, sign in
-
-
💻 Day 76 of #100DaysOfCoding Today’s problem was “Check If Digits Are Equal in String After Operations I” (LeetCode – Easy). The task was to repeatedly sum each pair of consecutive digits (mod 10) until the string becomes exactly two digits long and then check if both are equal. I used a simple and clear approach with a while loop and StringBuilder, updating the string in each iteration until it reduced to two digits. It’s a great example of how small logical patterns can make an otherwise repetitive problem neat and efficient ✨ #100DaysOfCoding #LeetCode #CodingJourney #ProblemSolving #Java #CodeEveryday #DSA #WomenInTech #SoftwareEngineering #LearningInPublic
To view or add a comment, sign in
-
-
Where does your technical debt really hide? Cyclomatic complexity, churn, coupling — Richard Gross demonstrates how to measure and visualize deep problems in large codebases objectively. Read now on JAVAPRO: https://lnkd.in/eENXrUwD #Java #DomainDrivenDesign #LegacyCode
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