After a long time, I solved a hard problem on LeetCode today. Small wins like this keep the learning journey exciting. 🚀 🚀 #Day82 of #100DaysOfCodeChallenge Today’s problem was a challenging one focused on Linked Lists and pointer manipulation. 📌 Problem: Reverse Nodes in k-Group (Hard) Given a linked list, the task is to reverse nodes in groups of size k. If the remaining nodes are fewer than k, they stay as they are. 🧠 Key Idea: Traverse the list and count k nodes. If k nodes exist, recursively process the remaining list. Reverse the current group of k nodes. Connect the reversed group with the result of the recursive call. Problems like this really test your understanding of how nodes connect and move inside a linked list. Consistency continues. One step closer to becoming better at problem solving every day. 💪 #100DaysOfCode #Day82 #LeetCode #DSA #LinkedList #Java #ProblemSolving #CodingJourney
Reversing Linked List Nodes in K-Groups on LeetCode
More Relevant Posts
-
🚀 Day 11 of #100DaysOfCode Solved LeetCode Problem #27 – Remove Element today! 💻 🔹 Approach: Used the Two Pointer Technique One pointer (i) iterates through the array Another pointer (ptr) keeps track of valid elements If nums[i] != val, assign it to nums[ptr] and increment ptr 🔹 Time Complexity: O(n) 🔹 Space Complexity: O(1) 💡 Key Learning: In-place array modification using two pointers helps optimize space and improves efficiency. 📌 Consistency is the key — one step closer every day! #LeetCode #DSA #Java #CodingJourney #Day11 #100DaysOfCode
To view or add a comment, sign in
-
-
🚀 Day 53 of #100DaysOfLeetCode Solved: Next Greater Element (Leetcode 496) Today’s problem was a great reminder of how powerful Monotonic Stack can be for optimization. 🔹 Approach: Used a stack to maintain decreasing elements Mapped each element to its next greater using a HashMap Reduced time complexity from O(n²) → O(n) 🔹 Key Learning: Small mistakes in conditions (like missing a !) can completely break logic. Attention to detail matters just as much as understanding the concept. 🔹 Complexity: Time: O(n + m) Space: O(n) Consistency > Perfection. Showing up daily and improving step by step. #LeetCode #DSA #Java #CodingJourney #ProblemSolving
To view or add a comment, sign in
-
-
Day 52 : Practicing Binary Trees on LeetCode 💡 Today’s live practical session in Alpha Plus 7.0 we solve some Binary Trees bases questions on LeetCode to test our logic. What I practiced today: ✅ Binary Tree Execution: Reinforced our core concepts by solving practical problems and tracing the exact flow of the nodes. ✅ Preorder Traversal: tackled the "Binary Tree Preorder Traversal" problem on LeetCode. ✅ Build the logic breakdown #BinaryTree #LeetCode #ProblemSolving #DSA #Java #SoftwareEngineering #100DaysOfCode #ApnaCollege
To view or add a comment, sign in
-
-
From confusion to clarity solved a LeetCode Hard today. 🚀 🚀 #Day83 of #100DaysOfCodeChallenge Today’s challenge focused on Linked Lists and merging multiple sorted structures efficiently. 📌 Problem: Merge k Sorted Lists (Hard) You are given k sorted linked lists, and the goal is to merge them into one sorted linked list. 🧠 Approach: Start with an empty result list. Iterate through each linked list in the array. Merge the current result list with the next list using a helper merge function. The helper function merges two sorted linked lists using the two-pointer technique. This problem is a great way to strengthen understanding of handling multiple linked lists and maintaining sorted order. Consistency continues learning and improving every day. 💪 #100DaysOfCode #Day83 #LeetCode #DSA #LinkedList #Java #ProblemSolving #CodingJourney
To view or add a comment, sign in
-
-
Day 75/200 – LeetCode Challenge Given a string of digits, the task is to generate all possible valid IP addresses by inserting dots. Sounds simple, but the challenge lies in handling. Try placing dots at every possible position. Validate each segment before moving forward. Prune invalid paths early to save time. Backtracking becomes powerful when combined with early pruning. Instead of exploring all possibilities, we cut off invalid paths immediately, making the solution efficient. Problems like this strengthen recursion + validation thinking. The more you practice, the better you get at spotting patterns. #Day75 #LeetCode #CodingChallenge #Java #200DaysOfCode
To view or add a comment, sign in
-
-
🚀 Day 51 of #LeetCode Challenge ✅ Problem: Third Maximum Number Today’s challenge focused on finding the third distinct maximum number in an array. If it doesn’t exist, we return the maximum value. 💡 Key Learning: Handling duplicates is the tricky part We must consider only distinct elements Instead of sorting, we can solve it efficiently in O(n) 🧠 Approach: Traverse the array once Keep track of the top 3 maximum values Update them carefully while ignoring duplicates ⚡ Outcome: This problem helped me improve my understanding of efficient array traversal and optimizing solutions without using extra space 📈 Complexity: Time: O(n) Space: O(1) #Day51 #LeetCode #Java #DSA #CodingJourney #ProblemSolving
To view or add a comment, sign in
-
-
🚀 Day 21 of my #100DaysOfCode Journey Today, I solved the LeetCode question Contains Duplicate II. The task is to check if there are two equal elements in the array such that their index difference is at most k. ✅ Steps: First, iterate through each element in the array For every element, check only the next k elements Compare values within this limited range If a match is found → return true 💻 My Approach: I used a sliding window + brute force approach (without using HashMap/HashSet). Instead of checking the whole array, I optimized it by limiting the inner loop to k distance only. 🌟 Learning Takeaways: Optimizing brute force can avoid TLE Understanding constraints (like k distance) helps reduce complexity Multiple approaches exist — choosing based on space/time is key #DSA #Java #LeetCode #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
🚀 Day 16 of My LeetCode Journey Today, I solved LeetCode Problem #747 – Largest Number At Least Twice of Others. 🔍 Problem Summary: Given an array of integers, we need to find whether the largest element is at least twice as much as every other number. If yes, return its index; otherwise, return -1. 💡 Approach I Used: First, find the largest and second largest elements in the array. Then check if the largest element is at least twice the second largest. If yes, return the index of the largest element. 🧠 Key Learning: This problem improved my understanding of: Array traversal Maintaining multiple variables (max & second max) Writing optimized O(n) solutions 📈 Progress: Consistency is the key 🔑 — improving step by step every day. #LeetCode #DSA #Java #CodingJourney #ProblemSolving #100DaysOfCode
To view or add a comment, sign in
-
-
🚀 Day 17 of My LeetCode Journey 📌 Solved: LeetCode #11 – Container With Most Water Today’s problem was a great example of applying the Two Pointer Approach efficiently. 🔍 Problem Summary: Given an array of heights, find two lines that together with the x-axis form a container that holds the maximum amount of water. 💡 Approach Used: Started with two pointers at both ends Calculated area using: min(height[left], height[right]) × width Moved the pointer with smaller height to maximize area ⚡ Key Learning: Instead of checking all pairs (O(n²)), we can optimize to O(n) using the two-pointer technique. 🧠 Time Complexity: O(n) 📦 Space Complexity: O(1) 🔥 Consistency is the key — learning something new every day! #LeetCode #DSA #Java #CodingJourney #ProblemSolving #100DaysOfCode
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
-
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