Even classic problems become powerful lessons when you focus on fundamentals. ✅ 🚀 #Day57 of #100DaysOfCodeChallenge Today was all about simulating real-world arithmetic using linked lists. A great reminder that data structures can mirror how we actually think about numbers. 📌 Problem 01: Add Two Numbers (Medium) Two numbers are given as linked lists where digits are stored in reverse order. The task is to add them and return the sum as a linked list. 🧠 Logic: Traverse both linked lists simultaneously. Add corresponding digits along with a carry. Store the result digit using modulo (sum % 10). Propagate carry using integer division (sum / 10). Use a dummy node to simplify list construction. Continue until both lists and carry are exhausted. Day 57 complete ✅ Still consistent. Still learning. 🚀 #100DaysOfCode #Day57 #LeetCode #DSA #LinkedList #Java #ProblemSolving #CodingJourney #LearnInPublic #Consistency
Linked List Arithmetic Challenge: Adding Two Numbers
More Relevant Posts
-
LeetCode 1752 — Check if Array Is Sorted and Rotated Solved another array logic problem today. At first it looked simple, but the real task was to observe the pattern in order changes, not just compare numbers blindly. Approach I used: - counted how many times the order breaks (nums[i] > nums[i+1]) - if it breaks more than once → not sorted & rotated - if it breaks once → last element must still fit before the first - otherwise → already sorted Result : Accepted Runtime : 0 ms What this problem made clear: - many array problems are really about pattern detection - a small logical observation can replace complex code - edge cases decide whether the solution is correct or not Small step, but clear learning. Continuing the grind. #LeetCode #DSA #Arrays #Java #ProblemSolving #LearningInPublic #CodingJourney
To view or add a comment, sign in
-
-
🚀 #PostLog129 Another LeetCode(#1545) problem solved : Find Kth Bit in Nth Binary String 🔹 Breaking down the recursive pattern step by step Build → invert → reverse → concatenate Break the process into predictable steps Focus on understanding the structure before optimizing 🔹 Building the solution incrementally instead of chasing optimization too early 🔹 Using string inversion + reversal logic to simplify understanding 🔹 Trusting clarity first, then refining for efficiency #LeetCode #DSA #Java #ProblemSolving #CodingJourney #SoftwareEngineering #Algorithms #InterviewPrep
To view or add a comment, sign in
-
-
Day 61/100 – LeetCode Challenge ✅ Problem: #190 Reverse Bits Difficulty: Easy Language: Java Approach: Bit Manipulation (LSB to MSB) Time Complexity: O(1) — fixed 32 iterations Space Complexity: O(1) Key Insight: Reverse bits by building result from least significant bit to most significant bit. For each bit position i (0 to 31): Extract i-th bit from original: (n >> i) & 1 Place it at reversed position: left shift result and OR with extracted bit Solution Brief: Loop 32 times (once per bit). Left shift rev to make room for new bit. Extract LSB from n at position i and OR it into rev. Return final reversed integer. #LeetCode #Day61 #100DaysOfCode #BitManipulation #Java #Algorithm #CodingChallenge #ProblemSolving #ReverseBits #EasyProblem #Binary #Bitwise #DSA
To view or add a comment, sign in
-
-
Day 11 of Daily DSA 🚀 Solved LeetCode 1800: Maximum Ascending Subarray Sum ✅ 🔍 Approach: Iterated through the array while maintaining the sum of the current strictly increasing subarray. Whenever the sequence breaks, a new subarray sum is started and stored. Finally, the maximum subarray sum is obtained from the stored values. This method clearly separates each ascending subarray and helps in understanding the problem flow. ⏱ Complexity: • Time: O(n) — single traversal + max lookup • Space: O(n) — list used to store subarray sums 📊 LeetCode Stats: • Runtime: 1 ms ⚡ • Memory: 43.30 MB A good learning step before optimizing further to constant space. #DSA #LeetCode #Java #Arrays #ProblemSolving #DailyCoding #Consistency
To view or add a comment, sign in
-
-
Day: 36/365 📌 LeetCode POTD: Longest Balanced Subarray II Hard Key takeaways/Learnings from this problem: 1. This one shows how segment trees help maintain balance info over ranges without recomputing everything again and again. 2. Big takeaway: when constraints grow, upgrading from prefix tricks to a range query data structure makes all the difference. #POTD #365DaysOfCode #DSA #Java #ProblemSolving #LearningInPublic #Consistency 🥷
To view or add a comment, sign in
-
🔹 Day 3 – DSA Consistency Journey Today, I solved LeetCode 693: Binary Number with Alternating Bits independently as part of my structured Data Structures & Algorithms practice. The problem focuses on verifying whether a number’s binary representation contains alternating bits (e.g., 1010…). I implemented an efficient O(log n) approach by iterating through each bit and validating adjacent comparisons. Problems like these reinforce: * Strong understanding of bit manipulation * Logical thinking with binary representations * Writing clean and efficient solutions Small, consistent steps every day are helping me sharpen problem-solving skills and strengthen core fundamentals. You can view my solution here: 🔗 https://lnkd.in/dbhAwWSC Looking forward to continuing this consistency journey. #DSA #LeetCode #ProblemSolving #SoftwareEngineering #ContinuousLearning #Java
To view or add a comment, sign in
-
-
Solved LeetCode #206 — Reverse Linked List. Problem: Given the head of a singly linked list, reverse the list and return the new head. Example: [1,2,3,4,5] → [5,4,3,2,1] Approach Used: Iterative Pointer Reversal Traverse the list while maintaining three pointers: • prev → stores the previous node • head → current node being processed • next → temporarily stores the next node For each node: Store next = head.next Reverse the pointer → head.next = prev Move pointers forward Continue until the list ends. prev becomes the new head of the reversed list. Complexity • Time Complexity: O(n) • Space Complexity: O(1) A classic linked list problem that strengthens pointer manipulation skills. #LeetCode #DSA #Algorithms #Java #CodingInterview #SoftwareEngineering
To view or add a comment, sign in
-
-
Day 5 of Daily DSA 🚀 Solved LeetCode 268: Missing Number Approach: Used the mathematical sum formula to calculate the expected sum of numbers from 0 to n. Subtracted the actual sum of array elements to find the missing number in a single pass. Complexity: • Time: O(n) • Space: O(1) LeetCode Stats: • Runtime: 0 ms (Beats 100%) • Memory: 47.57 MB A simple yet powerful problem that shows how math can replace extra space and lead to clean, efficient solutions. #DSA #LeetCode #Java #ProblemSolving #Arrays #Consistency
To view or add a comment, sign in
-
-
Day 18 – Solving 3Sum (LeetCode) Today I solved the 3Sum problem on LeetCode using an optimized approach 💻 🔹 Problem: Given an integer array, find all unique triplets whose sum is 0. 🔹 Example: Input: [-1, 0, 1, 2, -1, -4] Output: [[-1, -1, 2], [-1, 0, 1]] 🧠 What I learned How sorting helps reduce unnecessary comparisons How to use the two-pointer technique How to avoid duplicate triplets ⚙️ Approach Sort the array Fix one element Use two pointers to find the remaining two elements Skip duplicates This reduces time complexity from O(n³) to O(n²) 💡 Improving my Data Structures & Algorithms skills one day at a time #Day18 #LeetCode #3Sum #DSA #Java #CodingJourney #LearningInPublic
To view or add a comment, sign in
-
-
Day 22 of Daily DSA 🚀 Solved LeetCode 66: Plus One ✅ Approach: Treat the array as a number and simulate addition from the last digit: • If the last digit is not 9, increment and return • Handle carry by setting 9 → 0 and moving left • If all digits are 9, create a new array with leading 1 This avoids converting the array into an integer and handles large numbers safely. ⏱ Complexity: • Time: O(n) • Space: O(1) (extra array only when overflow happens) 📊 LeetCode Stats: • Runtime: 0 ms (Beats 100%) ⚡ • Memory: 43.58 MB (Beats 38.49%) A simple problem that tests edge-case thinking 💡 #DSA #LeetCode #Java #ProblemSolving #DailyCoding #Consistency
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
Awesome progress! Love how you’re breaking down classic problems into clear, practical lessons.