Could you please upload a video on how to find the maximum sum path of a binary tree? Here is the full question: Given a binary tree consisting of nodes with positive integer values, write a method that returns the maximum sum of data values obtained by traversing nodes along a path between any 2 nodes of the tree. The path must originate and terminate at 2 different nodes of the tree, and the maximum sum is obtained by summing all the data values of the nodes traversed along this path.
suppose there are 3 or more identical elements in the array subsequently, then how the array can be converted into wave form? I think this algorithm will not work out in that situation. Suppose the array is 2 5 5 5 6 1 3 can this be converted into wave form using this algorithm?
If you find the identical elements , then do nothing and go to next iteration........ And actually if you consider the wave condition , the identical elements make the wave longer....like one long wave in ocean .........and again the waves get back to normal as lesser and greater...
Code fails at
[1,2,2,1,2,1,1,1,1,2,2,2]
Explaining beautifully!
This algorithm doesn't work for [5,3,12,7,6,10,2,9,8]. It results [3,5,7,12,6,10,2,9,8] which is not a wave (first 4 are increasing only).
nice explanation sir
could you pls upload upload a video explaining diff between ZigZag array and wave array by giving an example
easiest way explained.....nice
Whats the difference between zig zag array and sort in wave form.. I thought array elements at last will be in sorted form..
For zig zag , a[i-1] < a[i] > a[i+1]
For wave , a[i-1] = a[i+1]
Hi Thanks for the feedback , i will edit the video and mention the difference..
it is not working for following input - [1,2,2,1,2,1,1,1,1,2,2,2]. Expected output - [1,2,1,2,1,2,1,2,1,2,1,2]
@@Whaleshamu Leetcode example
Wrong algorithm. Fails for duplicate elements in the array.
It is correct but only for distinct integer
Could you please upload a video on how to find the maximum sum path of a binary tree?
Here is the full question:
Given a binary tree consisting of nodes with positive integer values, write a method that returns the maximum sum of data values obtained by traversing nodes along a path between any 2 nodes of the tree. The path must originate and terminate at 2 different nodes of the tree, and the maximum sum is obtained by summing all the data values of the nodes traversed along this path.
sure I will upload the video on this question...
This is for unequal elements onyl
suppose there are 3 or more identical elements in the array subsequently, then how the array can be converted into wave form? I think this algorithm will not work out in that situation.
Suppose the array is
2 5 5 5 6 1 3
can this be converted into wave form using this algorithm?
If you find the identical elements , then do nothing and go to next iteration........
And actually if you consider the wave condition , the identical elements make the wave longer....like one long wave in ocean .........and again the waves get back to normal as lesser and greater...
thank you for the clarification
nice sir amazing video
sir please bfs and dfs ki implementation ki video dal dijiye sir .and n queen ki implementation bhi sir .execellent way of explaning in simple manner.
yes sure raj.
Sir wave sort is awiggle sort
.
yrr kya buckchodi hai ...kash urdu ya hind m hota :'(