🚀 Day 47of my #100DaysOfCode Journey Today, I solved the LeetCode problem: Mirror Distance of an Integer Problem Insight: Given a number, the task is to find the absolute difference between the original number and its reversed form. Approach: • Stored the original number in a temporary variable • Reversed the number using digit extraction (modulo and division) • Calculated the absolute difference between the original and reversed number Time Complexity: O(d), where d = number of digits Space Complexity: O(1) Key Learnings: • Digit manipulation using modulo and division is a powerful technique • Always store the original value before modifying the input • Reversing numbers is a fundamental pattern in many DSA problems Takeaway: Breaking the problem into simple steps makes even tricky-looking logic easy to solve. #DSA #Java #LeetCode #100DaysOfCode #CodingJourney
Solved LeetCode Mirror Distance of an Integer Problem
More Relevant Posts
-
💡 Day 55 of LeetCode Problem Solved! 🔧 🌟21. Merge Two Sorted Lists🌟 🔗 Solution Code: https://lnkd.in/gU7m-4wH 🧠 Approach: • Recursive Merge • Checked for null node base cases to identify the ends of the lists. • Recursively compared the current node values of list1 and list2. • Attached the smaller node to point to the recursively merged result of the remaining nodes. ⚡ Key Learning: • Leveraging recursion drastically simplifies Linked List operations, turning complex pointer-splicing logic into an elegant and readable sequence! ⏱️ Complexity: Time: • O(n + m) — where n and m are the lengths of the two lists Space. • O(n + m) — due to the recursion stack #LeetCode #Java #DSA #ProblemSolving #Consistency #100DaysOfCode #CodingJourney #LinkedList #Recursion
To view or add a comment, sign in
-
-
🚀 Day 49 of my #100DaysOfCode Journey Today, I solved the LeetCode problem: Set Mismatch Problem Insight: Given an array containing numbers from 1 to n, one number is duplicated and one number is missing. The goal is to find both of them. Approach: • Used a frequency array to count occurrences of each number • Traversed the input array and updated frequency • Iterated from 1 to n: – If frequency is 2 → duplicate element – If frequency is 0 → missing element • Returned both values as the final result Time Complexity: O(n) Space Complexity: O(n) Key Learnings: • Frequency array is a simple and powerful technique for counting problems • Helps quickly identify missing and repeating elements • Clean and easy-to-understand approach for beginners Takeaway: Sometimes the simplest approach is the most effective. Mastering basic patterns like counting can solve many problems efficiently! #DSA #Java #LeetCode #100DaysOfCode #CodingJourney
To view or add a comment, sign in
-
-
💡 Day 54 of LeetCode Problem Solved! 🔧 🌟 560. Subarray Sum Equals K 🌟 🔗 Solution Code: https://lnkd.in/g5VwiFKd 🧠 Approach: Prefix Sum & Hash Map Store cumulative sums in a Map Check for (current_sum - k) to find matching subarrays in one pass ⚡ Key Learning: Mastering the Prefix Sum + HashMap pattern is a game-changer for transforming $O(n^2)$ subarray problems into efficient $O(n)$ solutions. ⏱️ Complexity: Time: O(n) Space: O(n) #LeetCode #Java #DSA #ProblemSolving #Consistency #100DaysOfCode #CodingJourney #PrefixSum #DataStructures
To view or add a comment, sign in
-
-
🚀 Day 16 of LeetCode Problem Solving Solved today’s problem — LeetCode #26: Remove Duplicates from Sorted Array 💻🔥 ✅ Approach: Two Pointers ⚡ Time Complexity: O(n) 📊 Space Complexity: O(1) The task was to remove duplicates in-place from a sorted array and return the count of unique elements. 👉 I used the Two Pointer technique: One pointer to track unique elements Another to traverse the array 💡 Key Idea: Since the array is sorted, duplicates will be adjacent — making it easier to skip them. 👉 Core Logic: Compare nums[i] with nums[j] If different → move pointer and update value Maintain unique elements at the beginning 💡 Key Learning: Two Pointer is a very powerful technique for array problems — especially when data is sorted. Consistency is the key — getting better every day 🚀 #Day16 #LeetCode #DSA #Java #CodingJourney #ProblemSolving #100DaysOfCode
To view or add a comment, sign in
-
-
🚀 Day 43 of my #100DaysOfCode Journey Today, I solved the LeetCode problem: Sum of Unique Elements Problem Insight: Find elements in an array that appear exactly once and calculate their total sum. Approach: • Used a frequency array to count occurrences of each number • Traversed the array to build frequency • Added only those elements to sum whose frequency is exactly 1 Time Complexity: • O(n) Space Complexity: • O(1) (fixed size array used for constraints) Key Learnings: • Frequency array is faster than HashMap when range is fixed • Two-pass approach makes logic clear and simple • Always check constraints before choosing data structure Takeaway: Right data structure makes the solution simple and efficient 🚀 #DSA #Java #LeetCode #100DaysOfCode #CodingJourney #ProblemSolving
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
-
-
60-Day LeetCode Challenge – Day 43 Solved Check If Two String Arrays are Equivalent on LeetCode. 📌 Approach: Concatenated both string arrays into two strings and compared them using .equals(). 🧠 Learning: Reinforced how string building and comparison works, especially when data is split across arrays. ⚡ Complexity: • Time Complexity: O(n + m) • Space Complexity: O(n + m) Simple logic, but a clean reminder that breaking a problem down makes it easier to solve. #LeetCode #DSA #Java #Strings #Consistency #ProblemSolving #LeetCode60
To view or add a comment, sign in
-
-
Day 56 : Crushing Binary Trees on LeetCode 💡 Today’s live practical session in Alpha Plus 7.0 We focused on some of the most challenging Binary Tree questions on LeetCode, breaking down the logic behind them. What I practiced today: ✅ Tree Diameter: understand the logic to calculate the absolute longest path between any two nodes in the entire tree. ✅ Maximum Path Sum: Tackled a famous "Hard" level problem! Figured out how to find the path with the highest possible sum, even if it doesn't pass through the root. ✅ Target Deletion: Wrote the recursive code to systematically find and delete leaf nodes that match a specific target value. #BinaryTree #LeetCode #ProblemSolving #DSA #Java #SoftwareEngineering #100DaysOfCode #ApnaCollege
To view or add a comment, sign in
-
-
🚀 Day 69 — LeetCode Practice 🚀 Today’s focus was on string manipulation and careful indexing. ✅ Problem solved today: 🔹 Find Common Characters 💡 Key learnings from today: • Understood how to find common characters across multiple strings • Learned the importance of character frequency counting • Practiced handling nested loops efficiently • Realized how small mistakes in indexing can affect the entire logic • Improved attention to detail while working with strings Initially, I made a mistake by using the wrong variable inside charAt(). This caused incorrect indexing, which can either lead to wrong output or even StringIndexOutOfBoundsException. After fixing it, the logic worked perfectly by correctly comparing characters and tracking their minimum frequency across all words. This problem reinforced an important lesson: Sometimes errors are not in logic — but in small details like indexing and variable usage. Accuracy matters as much as logic. Step by step, getting better 💪 On to Day 70 🚀 #Day69 #DSA #LeetCode #ProblemSolving #Java #CodingJourney #Consistency #FutureEngineer
To view or add a comment, sign in
-
-
Day 90 - LeetCode Journey Solved LeetCode 2181: Merge Nodes in Between Zeros in Java ✅ This problem is all about smart traversal and building a new linked list on the go. I used a dummy node + running sum approach. As I traversed the list, I kept adding values until I hit a zero. Once a zero appeared, I created a new node with the accumulated sum and reset the sum for the next segment. Clean, intuitive, and efficient. Key takeaways: • Using dummy node to simplify list construction • Handling segments using running sum • Clean traversal without extra data structures • Strong understanding of linked list manipulation ✅ All test cases passed ⚡ O(n) time and O(1) extra space Problems like this improve your ability to think in segments and patterns 🔥 #LeetCode #DSA #Java #LinkedList #ProblemSolving #CodingJourney #InterviewPrep #Consistency #100DaysOfCode
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