sir u r the best teacher, u way of teaching made every thing easy
@sidharthpanda85574 жыл бұрын
I have been seeing numerous algo and ds videos. This is the best among them.
@yogeshsharma51683 жыл бұрын
This man is god for programmer who are struggling to understand programming, he made everything so easy🔥
@ranjanrohit645 жыл бұрын
You are the one who makes algorithm so easy to understand.. Lucky to watch your videos.. ❤️
@lakshay5105 жыл бұрын
ITS THE BEST EXPLANATION OUT THERE.
@Deepak-gj4ni3 жыл бұрын
Sir your content is must for every computer science student
@vibhugarg22487 жыл бұрын
Sir ,you are absolutely the person who is teaching such questions so nicely!Thankyou so much for the help !
@bhatanand2 жыл бұрын
Brilliant logic. Thanks for the video.
@reyou75 жыл бұрын
I love the he says POPPED 😍 You're great sir!
@amanueltassew8045 жыл бұрын
lol
@nemoahuja34232 жыл бұрын
Amazing explanation. Thank you so much!
@094_ramankumar93 жыл бұрын
Nice explanation very helpful
@asdbey7353 жыл бұрын
You're a lifesaver bro !! Do more of leetcode, InterviewBit and HackerRank solutions.
@siddhu89807 жыл бұрын
Simple and Amazing explanation.👍🏻👍🏻👍🏻
@lakshayhurria77035 жыл бұрын
Nice explanation liked the way you have drawn diagrams to explain
@namanvijay35144 жыл бұрын
Great Explanation, kudos!
@dpfit5 жыл бұрын
Hi Vivek. Thanks for the nice explanation.. It was very helpful.
@kamalsinghbisht19643 жыл бұрын
Great Explanation Sir
@jagadeeshp25584 жыл бұрын
Amma baboi thopu explanation 🔥🔥
@kabboghosh18535 жыл бұрын
best explanation on internet
@prashanttiwari1205 жыл бұрын
You are doing great job sir
@PhilGonzalez6 жыл бұрын
Great job, thank you for this explanation!
@sheldon02143 жыл бұрын
Nice work!
@tejaswinysingh86454 жыл бұрын
amazing explanation!
@robertcraig26622 жыл бұрын
Good explanation. Thnc
@ujjvalsharma50555 жыл бұрын
Hi Vivek your videos are amazing and you are a great teacher. Do you have online classes too or maybe be one-to-one doubt session on specific topics?
@amitkumargupta67224 жыл бұрын
just amazing...thanks a lot sir..
@akashbhadouria67275 жыл бұрын
Thank you🙏💕 sir and happy new year.
@ruchirai57755 жыл бұрын
awesome explanation !
@akashninave50013 жыл бұрын
Best explanation
@akashninave50013 жыл бұрын
SIR :)
@akshaysharma84924 жыл бұрын
awesome sir
@ranjanrohit645 жыл бұрын
Very well expalained sir.
@rahulkhandelwal465784 жыл бұрын
Thank you
@sudiptakumardas35474 жыл бұрын
Best vedio
@bishwajeet_b_das5 жыл бұрын
awesome teaching skill.
@pranaychandra80165 жыл бұрын
Great Explanation sir please solve more questions like this if you have any online course i am ready to buy it.
@jaytarwe27747 жыл бұрын
very well explained sir.
@keshavmaheshwari5213 жыл бұрын
mast sir
@ranjeetranjan87534 жыл бұрын
thanx sir
@sameerchaudhari85507 жыл бұрын
nice explanations long way to go !
@arjunsabu49274 жыл бұрын
Thank u sir
@vm16625 жыл бұрын
Great video! Thanks a lot. Quick question. Is it possible to solve this in constant time?
@ruchirsingh36357 жыл бұрын
nice sir ji
@veerrajuyeleti85418 жыл бұрын
good explanation
@premprakash82206 жыл бұрын
nice explanations
@travelogue45667 жыл бұрын
nice explanation sir
@vivekanandkhyade7 жыл бұрын
Thanks Chandan.!
@kausachan41673 жыл бұрын
clean
@SpiritualManish7 жыл бұрын
Nice Sir , Thank You :)
@rajanrocky72155 жыл бұрын
Code for the spiral model import java.util.LinkedList; import java.util.Queue; import java.util.Scanner; import java.util.*; //class representing Structure of treeNode in the binary tree class treeNode { int data; treeNode left; treeNode right; treeNode(int value) { data = value; left = null; right = null; } } class Source { static treeNode rootNode; void printSpiral(treeNode rootNode) { if (rootNode == null) return; // NULL check /*Create two stacks named "left2Right" used for printing the levels from left to right and "right2Lef" used for printing the levels from right to left.*/ Stack left2Right = new Stack(); Stack right2Left = new Stack(); // Push root node to the stack right2Left.push(rootNode); // printing the spiral order traversal of the tree while (!right2Left.empty() || !left2Right.empty()) { // print all the nodes in the level from left to right while (!right2Left.empty()) { treeNode tempNode = right2Left.peek(); right2Left.pop(); System.out.print(tempNode.data + " "); // push the right child and then push the left child to the stack "left2Right" if (tempNode.right != null) left2Right.push(tempNode.right); if (tempNode.left != null) left2Right.push(tempNode.left); } // Print all the nodes in the level from right to left while (!left2Right.empty()) { treeNode tempNode = left2Right.peek(); left2Right.pop(); System.out.print(tempNode.data + " "); // push the left child and then push the right child to the stack "right2Left" if (tempNode.left != null) right2Left.push(tempNode.left); if (tempNode.right != null) right2Left.push(tempNode.right); } } } public static void main(String[] args) { Source binaryTree = new Source(); //root node of the binary tree treeNode rootNode; Scanner in = new Scanner(System.in); //number of elements int n = in.nextInt(), element; //queue used to create a binary tree Queue q = new LinkedList(); // creating a new binary tree. rootNode = new treeNode(in.nextInt()); q.add(rootNode); treeNode cur = null; for (int i = 1; i < n; i++) { cur = q.remove(); //Note: if the element is -1 then the node is null element = in.nextInt(); if (element != -1) { cur.left = new treeNode(element); q.add(cur.left); } i++; //Note: if the element is -1 then the node is null element = in.nextInt(); if (element != -1) { cur.right = new treeNode(element); q.add(cur.right); } } //print the spiral order traversal of the tree binaryTree.printSpiral(rootNode); } }
@pulkitkaushik45394 жыл бұрын
thanks bete
@hrmeet05094 жыл бұрын
Its giving segmentation fault in GFG ! please update sir
@subhashishpanda10694 жыл бұрын
Great!
@pymondo11476 жыл бұрын
Thank you sir:)
@VikasGupta20145 жыл бұрын
You should start with recursive solution of the problem.
@veerrajuyeleti85418 жыл бұрын
sir could you do a video on given a binary tree find the largest subtree having atleast 2 other duplicate subtrees
@ajayrajrana43765 жыл бұрын
The best
@jonaskhanwald5663 жыл бұрын
The diagram itself is self explanatory
@subhampandey73746 жыл бұрын
What is the time complexity ? O(L) or O(N)
@NATANSHROCKS5 жыл бұрын
O(n)
@TotluTV5 жыл бұрын
how this is different from BFS?
@sandeepvedavyas87014 жыл бұрын
In bfs it would not be zigzag. It would print nodes from left to right in all levels unlike this problem where you have to print left to right and right to left for alternating levels.
@vikasvk91744 жыл бұрын
helpful .... :)
@kaasiworld6 жыл бұрын
Nice
@siddhu89807 жыл бұрын
Sir can u solve same problem in O(n)
@h3ct0rgr6 жыл бұрын
It is O(n) time, all nodes will be popped once from either stack. It is saving two child nodes for each so it is still in order of N.