You are not logged in. Please login at to post your questions!


Getting WA in Wealth Disparity?

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

arpit728's gravatar image

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_19982996★


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_19982996★


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

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • 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:


question asked: 08 Mar '18, 09:34

question was seen: 140 times

last updated: 09 Mar '18, 08:44