Maximum Binary Tree | leetcode 654 | Hindi

preview_player
Показать описание
Рекомендации по теме
Комментарии
Автор

Can you please add the solution for the O(n) Time complexity. I can't understand the intuition bheind that

sparshsharma
Автор

Pls explain optimized code....this is a basic approach that everyone can understand by reading discussion....

sudhanshusingh
Автор

I saw just 3 mins of video and solved the question. Thanks for the upload and clarification.

kirtimanmishra
Автор

Very well explained all algorithm video! Appreciated..Please add more videos lucky Kumar. I agreed with someone's comment that this is an underrated channel and it should have more subscribers and views for sure.

MrRaviBhavsar
Автор

What a great video, please keep uploading more videos, subscribed :)

siddharth
Автор

Very neat code and nice explanation! Thx!

anant
Автор

need optimized code explaination using stack

hellohi-uyhq
Автор

Please explain this... with Monotonic Stack which reduces TC

ommapari
Автор

Your Videos are just Awesome, bro please
do make one seperate playlist on binary tree that contains all good problems

pragneshamadavadi
Автор

bhaiya can you please suggest some tree construction questions on leetcode easy-medium

PIYUSH-lzzq
Автор

My C++ code:
TreeNode* buildtree(vector<int> &nums, int start, int end)
{
int maxi=INT_MIN, index=-1;
for(int i=start;i<=end;i++)
{
if(nums[i]>maxi)
{
maxi=nums[i];
index=i;
}
}
if(index==-1)
return NULL;
TreeNode *root=new TreeNode(nums[index]);
root->left=buildtree(nums, start, index-1);
root->right=buildtree(nums, index+1, end);
return root;

}
TreeNode* nums) {
return buildtree(nums, 0, nums.size()-1);
}

vibeStationPS
Автор

people come here to search the optimal solution, not a brute force solution

shivangagrawal
Автор

what is the time complexity of this algorithm

raghavjha
Автор

Awsm explaination sir.. Can you plz make one video on factor combinations problem on leetcode.

rupalitiwari
Автор

Amazing lectures.
You have not been posting for sometime.
Really missed your videos

aparajitapandey
Автор

this is not a very good solution because time complexity here is o(n2)

ROUNAKSHARMAgsme
Автор

can you help me whats wrong with this code
class Solution {
public:
int m(vector <int> nums, int l, int r)
{
int i;
int m=l, mv=nums[l];

for(i=l;i<=r;i++)
{
if(nums[i]>mv)
{mv=nums[i];
m=i;
}}
return i;
}
TreeNode *construct(vector <int> nums, int l, int r)
{ if(l>r)
return NULL;
else if(l==r)
{TreeNode *root=new TreeNode(nums[l]);
return root;
}
else{
int t=m(nums, l, r);

TreeNode *root=new TreeNode(nums[t]);
root->left=construct(nums, l, t-1);
root->right=construct(nums, t+1, r);
return root;

}

}
TreeNode* nums) {
TreeNode *root=NULL;

return construct(nums, 0, nums.size()-1);



}
};

ashishsemwal
join shbcf.ru