Interview Question

Revision en1, by gXa, 2017-05-22 00:19:17

A tree is given in which each edge is having some weight associated with it and you are given a number K.

So starting from root in K-steps how much maximum weight you can collect. You can traverse in any direction either from parent to child or child to parent. You can visit a node multiple times.

Spoiler
Tags #interview

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en4 English gXa 2017-05-22 00:21:40 2 Tiny change: '1, ans=6\nFor K=2,' -> '1, ans=6\n\nFor K=2,'
en3 English gXa 2017-05-22 00:21:02 16 Tiny change: '` \n\n\n\n<s' -> '` \n\n\n\n\n\n\n\n<s'
en2 English gXa 2017-05-22 00:19:33 6 Tiny change: 's.\n` \n\n<spoil' -> 's.\n` \n\n\n\n<spoil'
en1 English gXa 2017-05-22 00:19:17 504 Initial revision (published)