×

# Getting WA in Wealth Disparity?

 0 I am attempting the Wealth Disparity problem but I am getting wrong ans. This is link to my solution, anyone please help me in debugging what is wrong with my code. asked 08 Mar '18, 09:34 1★arpit728 683●15●62 accept rate: 10% I think u've misread the question,we want max(diff(i-j) for all childs j of i) for all i (08 Mar '18, 14:04) @vivek_1998299 I have made an assumption which is, if 'b' is parent of 'a' and 'x' is the value which gave the maximum difference for 'b' then the maximum difference for 'a' will be given either by the sam value x i.e., x-A[a] or by A[b]-A[a] this could be summed up as diff[a]=max(x-A[a], A[b]-A[a]). Let me know if anything is wrong with this assumption. (09 Mar '18, 07:22) arpit7281★ U could just take min of subtree of i and subtract it from i (09 Mar '18, 07:28) @vivek_1998299 In problem statement it is said that wealth falls rapidly as one goes down the organizational tree but in the given test case the owner's wealth is less then 4th employee. Can you please explain how this is possible. (09 Mar '18, 08:44) arpit7281★
 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×1,197
×693
×126

question asked: 08 Mar '18, 09:34

question was seen: 140 times

last updated: 09 Mar '18, 08:44