❓DSA #287 - Requirements needed to construct a unique BT
✅Solution - This was a conceptual question. Lets say if you have inorder, preorder and post order, what will give a unique BT? Only one of them can't. We need two of them. Check this out:
- Pre-Order: Gives guarantees the location of root node
- Inorder: Gives us left and right subtrees (if we can figure out root)
- Post-Order: Gives guarantees the location of root node
This means any traversal in combination with inorder can give us a unique BT.
#dsa
I have a different take, Industry is moving pretty fastly, if you don't do development now, you wont get placed. Right now leaving the top MNCs, no good companies are hiring the 'DSA Experts', they need good developers.
I will say you have time, do 3-4 DSA problems daily, and dedicate all left time to development
❓ DSA #285 - Count total nodes in a complete BT [in < O(n) TC]
✅ Solution - Recursively checkout out the height of left subtree and right subtree, until leftheight = rightheight, than simply (2^height+1) gives count of nodes. Recursively calculated the height while backtracking
#DSA
I have a different take, Industry is moving pretty fastly, if you don't do development now, you wont get placed. Right now leaving the top MNCs, no good companies are hiring the 'DSA Experts', they need good developers.
I will say you have time, do 3-4 DSA problems daily, and dedicate all left time to development
hahaha i am no 'sir' kavya, a good project is one that shows that you solved a very complex problem. It should not be what everyone is building or a tutorial follow up (like ecom site etc etc).
When someone sees it, they should feel like its not 'just a project', its a 'product' ready to be used by thousands of users.
There is no problem in developing what's already made, like a linear clone, google meet, etc, just it should be a very polished product.
❓ DSA #284 - Print all nodes at a distance of K in BT
✅ Solution - Did a BFS , Created a map to store parent and nodes, so that we can travel left, right, parent.
Did BFS again maintaining a visited hashSet, did node->left, node->right, node->parent, Distance incremental. When distance = K, all the elements in the queue are our answer.
#DSA
❓ DSA #283 - Maximum Width of BT
✅ Solution - Did a BFS (Level Order), Created custom data structure Pair(TreeNode, Index), while traversing on BT i added actual index of every node. 0 based indexing.
At every level iteration i determine if its the first element of the level, store it in 'first', if its the last element of the level, store it in 'last'.
In the end 'ANS = MaxOf(ANS, last-first+1);
#DSA
@____protagonist And well mail is just for the picture, i apply on all the platforms, get assignments, do submit it on time, no replies.. thats what i am actually sick of
#Buildinpublic - Creating codeginie: OpenSource AI coding agent
Codeginie AI agent status - Have built a working AI agent that can help you create projects.
#webdev