Pramp Mock Technical Interview - Data Structures and Algorithms

  Рет қаралды 70,223

Nick White

Nick White

Күн бұрын

Пікірлер: 88
@shreejitnair2174
@shreejitnair2174 4 жыл бұрын
wowww Nick you struggling with this question I assumed you were trying to play along or something to show how a mock interview looks like. I am just used to all your new videos :) Awesome progress. Great lessons for strugglers, keep chugging along. Love your videos :)
@OverLordOfDa3rdWorld
@OverLordOfDa3rdWorld 4 жыл бұрын
wow, this is amazing! I was so afraid of what pramp would be like! Thanks for this!!
@fathimhiri5926
@fathimhiri5926 2 жыл бұрын
i just opened this video, before i fix a peer to peer interviews lol, i wanted to see how it like before
@akibislam8599
@akibislam8599 3 жыл бұрын
You can use DFS passing the value of current_sum to every child node. At the leaf node, you need to compare the current_sum with the global_min_sum, if (current_sum
@veipuniilana1842
@veipuniilana1842 2 жыл бұрын
static class SalesPath { int result = 0; int getCheapestCost(Node rootNode) { // your code goes here if(rootNode==null){ return 0; } helper(rootNode,0); return result; } void helper(Node rootNode,int cumResult){ cumResult = rootNode.cost; if(rootNode.children==null){ result = Math.min(result,cumResult); } for(Node child:rootNode.children){ helper(child,cumResult); } } } do you think this will work?
@barretp
@barretp Жыл бұрын
@@veipuniilana1842 First line of the helper function should be cumResult = rootNode.cost + cumResult
@ok2pro
@ok2pro 3 жыл бұрын
For the first question, I solved it by gathering array of dead end nodes and while loop up to parent calculating costs until parent is nil for each of the nodes.
@laffed2045
@laffed2045 4 жыл бұрын
1:04 She's so cool about it
@StockDC2
@StockDC2 4 жыл бұрын
If space complexity isn't an issue, the second one can be easily solved by converting the tree into an array and then doing a linear/binary search. Once the target element is found, just return the node to the right of it. If the index is out of bounds, just return null. Not the most efficient but it works.
@Schnorzel1337
@Schnorzel1337 4 жыл бұрын
This suggestion is redicolous. You want to traverse the tree to turn it into an array (n Operations) then traverse your new array to find the solution. If you are able to turn the tree into an array you must be able to solve this problem. And there is no known data structure better for binary search than a binary search tree. Think about the name.
@vishvaschoudhary3858
@vishvaschoudhary3858 4 жыл бұрын
More simpler approach would be to have a prev variable, do inorder search and if prev == target return current value otherwise if nothing returns return null
@淮都先生
@淮都先生 4 жыл бұрын
I guess dfs+backtracking is what the problem wants to check after first glance.
@karthikmucheli7930
@karthikmucheli7930 5 жыл бұрын
The first question. I am just 5 mins in, it seems simple. Just DFS and return the min sum.
@g_455
@g_455 4 жыл бұрын
Can you share the code please
@StockDC2
@StockDC2 4 жыл бұрын
@@g_455 I did it in Javascript but here's my solution. Please note that the initialization of the tree was done by someone else; I don't take any credit for it. I think the code is very easy to follow (no weird tricks) but if you need help, please let me know. repl.it/repls/DimFeistyRuntime
@cryptoisk1ng
@cryptoisk1ng 4 жыл бұрын
That is not the most optimal, this is just Dijkstra's algorithm which is BFS with Min Heap
@ishaansingh9212
@ishaansingh9212 4 жыл бұрын
Karthik Mucheli u should use pre cost totals instead...the node class should have a list of possible costs
@Aziqfajar
@Aziqfajar 4 жыл бұрын
I thought the solution would be to find minimal cost, since it says that return the minimum. So, by iterating for every node would be the solution, even if the time complexity would be n^2.
@Aziqfajar
@Aziqfajar 4 жыл бұрын
This interview is smoother than a butter on a toasted bread.
@hungryXD
@hungryXD 3 жыл бұрын
WOAH! THAT'S REALLY SMOOTH!!! 😲
@yechanlee7066
@yechanlee7066 3 жыл бұрын
Isn't the first question just a variation of leetcode PathSum? Just adding a min counter will be enough.. It's an easy question in leetcode.
@some_20s_guy
@some_20s_guy 4 жыл бұрын
I liked the idea about how you let the interviewee to think about her approach, instead of blabbering away about the question. Seems quite annoying when you don't get the time to read the problem 😁
@nicoqueijo
@nicoqueijo 4 жыл бұрын
Isn't it weird that these Node classes have references to their parents? Kinda gives tree problems a new meaning...
@hatrick3117
@hatrick3117 4 жыл бұрын
Yeah... I don't like it, It's like you found a solution but there is this parent that you never used, and it's bothers you, like you missed some secret.
@joecamroberon9322
@joecamroberon9322 5 жыл бұрын
Please do more of these if you can!!!
@NickWhite
@NickWhite 5 жыл бұрын
just made another video will post it soon
@joecamroberon9322
@joecamroberon9322 5 жыл бұрын
Nick White sounds great. I just spent like 5 hours today watching your vids. Going to hop on hackerrank tomorrow and solve some problems. Also, thanks for the inspiration and motivation.
@yodgorbekkomilov3383
@yodgorbekkomilov3383 4 жыл бұрын
@@joecamroberon9322 good luck mate I have an interview today
@ozzyfromspace
@ozzyfromspace 2 жыл бұрын
Yo! I was on Pramp earlier today and actually got this question 😅. What are the odds of that? Somehow the interview gods were with me and I found an efficient solution.
@veipuniilana1842
@veipuniilana1842 2 жыл бұрын
tell me your approach to the solution
@driziiD
@driziiD 4 жыл бұрын
BFS -- Shortest Paths Problem -- Dijkstra's Algorithm -- Travelling Salesman
@lakshminarayan1564
@lakshminarayan1564 4 жыл бұрын
Isn't this supposed to be DFS?
@Schnorzel1337
@Schnorzel1337 4 жыл бұрын
@@lakshminarayan1564 Yes and it is. The call is root -> child[0] -> child[0] .... -> child
@Schnorzel1337
@Schnorzel1337 4 жыл бұрын
This is not shortest paths problem. Dijkstra answers exactly this: What is the min distance from Node x to Node y of a graph. We want to answer, what is the min distance from Node x to all leaves {l1,l2,...,ln) thats closer to floyd warshall than anything. But still wrong, any tree traversial can solve this. And no, Travelig salesman cant work on a tree, because any graph that is not hamiltonian cant have a solution. And TSP is not even solvable for that many nodes.
@kushaljha5415
@kushaljha5415 3 жыл бұрын
root to leaf problem this is very easy prob imo
@rohitkumar2984
@rohitkumar2984 4 жыл бұрын
I had to build the tree in pramp interface to test it.
@huxiaoxu
@huxiaoxu 4 жыл бұрын
I think the solution is that BFS with Priority Queue.
@PoulJulle-wb9iu
@PoulJulle-wb9iu 4 жыл бұрын
PQ why ??
@MrKrazeeNinja
@MrKrazeeNinja 4 жыл бұрын
@@PoulJulle-wb9iu optimise the solution to get to the shortest path first rather than test unnecessary neighbours
@dhananjayand3057
@dhananjayand3057 4 жыл бұрын
Change the LinkedIn link in your description. Check the link mate
@marcosissler
@marcosissler 8 ай бұрын
Wow, thank you guys for sharing this experience. Amazing and super useful.
@yuliu8652
@yuliu8652 4 жыл бұрын
For first question, you can use post order of tree, from leave to root
@ishaansingh9212
@ishaansingh9212 4 жыл бұрын
Yu Liu that’s what i was thinking, more efficient
@Schnorzel1337
@Schnorzel1337 4 жыл бұрын
Whats wrong with good old preorder? You visit every node exactly once, thats optimal without pruning allowed.
@Schnorzel1337
@Schnorzel1337 4 жыл бұрын
@@ishaansingh9212 How is that more efficient?
@rockgamerz2064
@rockgamerz2064 4 жыл бұрын
I think preorder is better.
@abhishekkadam2999
@abhishekkadam2999 4 жыл бұрын
I am surprised that no one has yet commented on this, but, I think the first solution won't work.
@hawktomnia007
@hawktomnia007 4 жыл бұрын
he declared min_cost outside of the function as a global variable and then returns min_cost for each recursive call. It's confusing
@lekdendorji6a
@lekdendorji6a 4 жыл бұрын
Declaringthe min cost outside the function wont workk
@g_455
@g_455 4 жыл бұрын
It would be great if you can share the code for the solutions as well
@calmVlogsKannadiga
@calmVlogsKannadiga 4 жыл бұрын
I think kurskal or djikstra's algorithms can be used and modified a bit to find an effective solution
@Schnorzel1337
@Schnorzel1337 4 жыл бұрын
(Kruskal) A Minimum Spanning Tree is not a solution to this problem, also you got a tree not the list of vertices so you would need to visit the tree just to find all vertices and then do Kruskal which would output the tree. A Minimum Spanning Tree of a tree, is the tree itself. (Dijkstra) Again wouldnt work because you dont have the vertices. And what would be the question? The minimum path from the root to every leaf? Thats not Dijkstra anyway. Thats half way to Floyd Warshall. The shown algorithm is nearly optimal (if the global variable would be inside the function) and you shouldnt reinvent the wheel. Only thing you can add is, if you got the minimum for the left tree you can stop traversing the right tree if the cost is matched or exceeded.
@amangottumukkala2929
@amangottumukkala2929 4 жыл бұрын
I really appreciate your content, but your first solution is completely incorrect. It's been a while since this was uploaded so I'm sure you know how to solve it now :)
@sanskarkaazi3830
@sanskarkaazi3830 2 жыл бұрын
Can I get the problem link to this question?
@veipuniilana1842
@veipuniilana1842 2 жыл бұрын
static class SalesPath { int result = 0; int getCheapestCost(Node rootNode) { // your code goes here if(rootNode==null){ return 0; } helper(rootNode,0); return result; } void helper(Node rootNode,int cumResult){ cumResult = rootNode.cost; if(rootNode.children==null){ result = Math.min(result,cumResult); } for(Node child:rootNode.children){ helper(child,cumResult); } } } is this right?
@somak4522
@somak4522 4 жыл бұрын
You are a good guy nick ✌️
@hasa4628
@hasa4628 2 жыл бұрын
Did u know the questions before the interview
@andrewv8548
@andrewv8548 4 жыл бұрын
I have no idea what she's saying half of the time
@JamesBond-bi2cr
@JamesBond-bi2cr 10 ай бұрын
These Chinese can't even pronounce properly
@iohin
@iohin 7 ай бұрын
That’s often how real interviews go
@cooldhongibaba
@cooldhongibaba 4 жыл бұрын
I'm still confused about the first solution tho. Because of the fact that min_value is a class member and once it reaches, for example the branch 1 -> 1 it would assign the value of min_value to 2 => rootNode.cost + getCheapestCost(child ). Once it assigns that value to min_value, it wont change throughout the whole search. Any thoughts?!
@vishvaschoudhary3858
@vishvaschoudhary3858 4 жыл бұрын
Yeah so the idea of min_value is to not compare it with the sum before we reach the leftmost child which can be done with preorder in which we'll recursively call the leftmost child and adding the node value than compare it with min_value
@bauyrzhanmaksot3022
@bauyrzhanmaksot3022 5 жыл бұрын
you have to visit at least each node once, here you are traversing through children of the root node.
@Schnorzel1337
@Schnorzel1337 4 жыл бұрын
You missed the recursion. He visits every node.
@shufflingutube
@shufflingutube 4 жыл бұрын
gosh algorithms are hard
@pankaj3746
@pankaj3746 9 ай бұрын
Nick is pretending to be a begineer, that's kind of funny! I don't solve that many leetcode questions, but the first one is so simple, even I recognized that it's a depth-first-traversal problem!
@AaronBondSU
@AaronBondSU 5 жыл бұрын
are you still streaming on twitch?
@NickWhite
@NickWhite 5 жыл бұрын
Aaron Bond yeah but I’m just trying to grow my KZbin right now I’ll probably go live again soon enough
@istiaque-ahmed
@istiaque-ahmed Жыл бұрын
Why don't you upload new video please ?
@tejassardana6266
@tejassardana6266 4 жыл бұрын
Her smile is so cute
@powerToYourself36
@powerToYourself36 4 жыл бұрын
This is so cool 😎
@iohin
@iohin 7 ай бұрын
1:00 l i don’t have too many people…” 300k subscribers
@captainalpha4853
@captainalpha4853 4 жыл бұрын
Great video!
@risingpower
@risingpower Ай бұрын
"i don't have a lot of people" 384k subs later... hahaha
@PoulJulle-wb9iu
@PoulJulle-wb9iu 4 жыл бұрын
how this guy got interview at google? GG mate. she rocked it though
@MElixirDNB
@MElixirDNB 4 жыл бұрын
why dont you watch his 5000 videos where he solves typical interview questions dumb dumb
@MElixirDNB
@MElixirDNB 4 жыл бұрын
@@doublesid1395 No its not, its all about practice. The more you do it the easier it is to do, whether someone is watching or not. With practice you also get confidence so its not so nerve wracking in front of other people, plus they are usually nice and helpful
@pinkylover911
@pinkylover911 2 жыл бұрын
your peer is cute :)
@JSDev776
@JSDev776 3 жыл бұрын
such acting much wow! LOL
@rohitkumar2984
@rohitkumar2984 4 жыл бұрын
I had to build the tree in pramp interface to test it.
Live Mock Interview | Data Structure and Algorithms Technical Round
47:49
React Coding Interview Ft. Clément Mihailescu
47:08
Conner Ardman
Рет қаралды 134 М.
Try Not To Laugh 😅 the Best of BoxtoxTv 👌
00:18
boxtoxtv
Рет қаралды 7 МЛН
MAGIC TIME ​⁠@Whoispelagheya
00:28
MasomkaMagic
Рет қаралды 38 МЛН
Миллионер | 2 - серия
16:04
Million Show
Рет қаралды 1,9 МЛН
Wait for it 😂
00:19
ILYA BORZOV
Рет қаралды 11 МЛН
I Got Rejected (again)
9:43
Nick White
Рет қаралды 205 М.
Medium Google Coding Interview With Ben Awad
51:27
Clément Mihailescu
Рет қаралды 1,3 МЛН
Google Coding Interview With A Facebook Software Engineer
49:59
Clément Mihailescu
Рет қаралды 942 М.
Array of Array Products | Pramp
29:20
Abanoub Asaad
Рет қаралды 1 М.
Easy Google Coding Interview With Ben Awad
28:00
Clément Mihailescu
Рет қаралды 1 МЛН
Mock Technical Interview - Javascript Developer Entry Level
1:36:22
Tech with Nader
Рет қаралды 504 М.
Try Not To Laugh 😅 the Best of BoxtoxTv 👌
00:18
boxtoxtv
Рет қаралды 7 МЛН