Problem Statement: You are given an binary tree, you need to convert into sum tree. Example Solution We can solve this problem with the help of recursion. Then we store the old value of the current node and recursively call for left and right sub tree …
Problem Statement: You are given a binary tree, you need to traverse diagonal and print the nodes. Example The diagonal traversal is : 10 20 30 5 15 16 4 14 Solution We shall use queue to solve the problem. We follow below steps: …
Problem Statement: You are given an LL, you need to segregate the list such that all the even number appear before all the odd numbers in the modified list. Example Input: 1 -> 2 -> 3 -> 4 -> 5 -> 6 -> 7 -> …
Problem Statement: You are given 2 LL, you need to get the multiplication of the 2 LL. Example Input: 1 -> 2 2 Output: 24 Solution We follow bellow steps for the solution: 1. Initialize a variable 2. Start traversing the LL 3. Add …