A helper function (inorder) recursively traverses the tree and updates pointers. The first node encountered becomes the head of the DLL, and the final result is printed in both forward and reverse order.
#geekstreak2024#DeutscheBank
Day 3 of 21 Days POTD Challenge Powered By Deutsche Bank
Problem: Alternate positive and negative numbers
Approach: Separate positive and negative values, then push it into the new array in alternate manner. Copy new array to original array.
#geekstreak2024#DeutscheBank
Day 2 of 21 Days POTD Challenge Powered By Deutsche Bank
Problem - Given a Binary Tree, convert it into its mirror.
Approach - Use Recursion. Best way for solving Tree Problems.
#geekstreak2024#DeutscheBank
Day 1 of 21 Days POTD Challenge Powered By Deutsche Bank
Problem - Given the head of a linked list, the task is to find the middle. Eg - The middle of 1-> 2->3->4->5 is 3. If there are two middle nodes (even count), return the second middle.
My Approach - This approach is two-pointer technique. One pointer (fast) moves two steps at a time while the other (slow) moves one step. When the fast pointer reaches the end, the slow pointer is at the middle, returning its data. This method ensures a time complexity of O(n).