Day 17 of #100DaysOfCode Solved Plus One (Easy) today. A simple but important problem that reinforces handling edge cases carefully. Key Idea: Traverse from the last digit, handle carry properly. Approach: Start from the end of the array If digit < 9 → increment and return If digit == 9 → make it 0 and carry forward If all digits are 9 → create new array with leading 1 Learning: Even the easiest problems test your attention to edge cases. Consistency > Complexity. #LeetCode #DSA #CodingJourney #Java #ProblemSolving #Consistency
Solving Plus One Problem with Edge Case Handling
More Relevant Posts
-
🚀 Day 27/100 Days of Code Challenge Today’s problem: Find Peak Element (Leetcode 162) 🔍 What I learned: How to find a peak element efficiently without scanning the entire array Using Binary Search to reduce time complexity from O(n) to O(log n) Understanding how the “slope” of elements helps decide the search direction 🧠 Key Idea: Instead of checking every element, compare the middle element with its neighbor: If nums[mid] < nums[mid + 1] → move right Else → move left ✅ Example: Input: [1, 2, 3, 1] Output: 2 (index of peak element 3) Consistency is key 🔑 — improving problem-solving skills one day at a time! 💪 #Day27 #100DaysOfCode #LeetCode #BinarySearch #DSA #Java #CodingJourney
To view or add a comment, sign in
-
-
Day 34 🚀 | Consistency in Action Another day, another problem solved ✅ Today’s focus was on optimizing array manipulation — keeping things simple, efficient, and in-place. 💡 Key takeaway: Sometimes the best solutions aren’t complex — just smart pointer movement and clean logic. ⚡ Performance: • Time: 2 ms (Beats 91.13%) • Space: Optimized in-place Small steps every day → Big growth over time. #Day34 #LeetCode #DSA #CodingJourney #Consistency #ProblemSolving #Java #100DaysOfCode
To view or add a comment, sign in
-
-
🔥 Day 58 of #100DaysOfCode Solved – Check Balanced String 🔍 What I did: Traversed the string and calculated the sum of digits at even and odd indices separately, then compared both sums to determine if the string is balanced. 💡 Key Learning: Practiced string traversal and indexing Improved understanding of even vs odd index logic Learned how to convert char to integer (c - '0') 🎯 Takeaway: Even simple index-based problems can strengthen your fundamentals and attention to detail. #Day58 #LeetCode #Java #ProblemSolving #CodingJourney #100DaysOfCode #DSA
To view or add a comment, sign in
-
-
🚀 Day 29/100 – #100DaysOfCode Today’s problem: Middle of the Linked List (LeetCode 876) 🎯 💡 What I learned: How to find the middle node efficiently using the two-pointer (slow & fast) approach Understanding why the fast pointer moves twice as fast as the slow pointer Handling both odd and even length linked lists Writing optimal code with O(n) time and O(1) space 🧠 Key Idea: Use two pointers: slow → moves 1 step at a time fast → moves 2 steps at a time 👉 When fast reaches the end, slow will be at the middle! 📊 Complexity: Time: O(n) Space: O(1) 📈 One step closer to mastering Linked Lists..... #Day29 #100DaysOfCode #LeetCode #LinkedList #DSA #Java #CodingJourney #ProblemSolving #TechSkills
To view or add a comment, sign in
-
-
Day 78 of #LeetCode 🚀 Solved: Number of Steps to Reduce a Number to Zero Today’s problem was simple but a great reminder of how important basic logic and loops are. 💡 Key Idea: If number is even → divide by 2 If odd → subtract 1 Repeat until it becomes 0 📌 Focus: Strengthening fundamentals Writing clean and efficient logic Consistency > Complexity 💯 Slowly building problem-solving mindset every day. #Day78 #CodingJourney #Java #DSA #LeetCode #Consistency #FutureDeveloper
To view or add a comment, sign in
-
-
Day: 96/365 📌 LeetCode POTD: Minimum Distance to Type a Word Using Two Fingers Hard Key takeaways/Learnings from this problem: 1. This problem is a great example of DP with state as both fingers’ positions, which feels tricky at first but clicks once you model it right. 2. Key learning: instead of deciding both fingers every time, fix one and optimize the movement of the other to reduce complexity. 3. Precomputing distances between characters makes transitions much faster and keeps the code clean. #POTD #365DaysOfCode #DSA #Java #ProblemSolving #LearningInPublic #Consistency 🥷
To view or add a comment, sign in
-
-
🚀 Day 54 of my #100DaysOfCode Journey Today, I solved LeetCode – Sort Array By Parity II Problem Insight: Rearrange the array such that even-indexed positions have even numbers and odd-indexed positions have odd numbers. Approach: • Created a new result array of same size • Used two pointers: evenplace = 0 and oddplace = 1 • Traversed the array once • Placed even numbers at even indices and odd numbers at odd indices • Incremented pointers by 2 to maintain correct positions Time Complexity: O(n) | Space Complexity: O(n) Key Takeaway: Using two pointers for index placement makes the solution clean, efficient, and avoids unnecessary swaps. #DSA #Java #LeetCode #100DaysOfCode #CodingJourney
To view or add a comment, sign in
-
-
100 Days of Code Day - 24 🔁 Swap Nodes in Pairs – LeetCode Problem Solved a classic Linked List problem today! 💡 👉 Given a linked list, swap every two adjacent nodes without modifying values — only changing the links. ✅ Example: Input: [1,2,3,4] Output: [2,1,4,3] 💭 Approach: Used a dummy node and pointer manipulation to efficiently swap nodes in O(n) time and O(1) space. 📌 Key Learning: Understanding pointer handling is crucial for mastering Linked Lists. #LeetCode #Java #DSA #LinkedList #CodingJourney #ProblemSolving
To view or add a comment, sign in
-
-
#Day89 Of Problem Solving Solved today’s LeetCode Daily Question and got it accepted with all 113/113 test cases passing.What stood out this time wasn’t just getting the correct answer, but refining the approach to keep it clean and efficient. The solution uses a simple HashSet-based technique in Java to track elements and check conditions in linear time. Runtime: 2 ms (faster than 97.89% of submissions). Memory usage: something to improve going forward. Small wins like this remind me that consistency matters more than complexity. Writing simple, readable code and understanding why it works always pays off.On to the next problem. #LeetCode #DSA #Java #CodingJourney #ProblemSolving #Consistency #LinkedIn
To view or add a comment, sign in
-
-
#Day82 Of Problem Solving Solved today’s LeetCode Daily Question and got all test cases accepted. Focused on finding the minimum distance between the target element and the given start index. Kept the approach simple—iterated through the array and updated the minimum distance using Math.abs(). Clean logic, efficient, and gets the job done. Performance: Runtime: 1 ms Memory: 45.04 MB Small problems like this are a good reminder that clarity in thinking often beats overcomplication. Staying consistent with daily practice. #LeetCode #Java #ProblemSolving #DSA #CodingJourney #LeetCode #LinkedIn
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