Since one employee has at most one direct leader and may have several subordinates. so it should be only added once
5+3+3+2=13 so output is 13 and but it was Expected as 15.
if thats not the case shouldnt we return -1?
[[1, 5, [2, 3]], [2, 3, ], [3, 3, ], [4, 2, ]]
So you want to add a test case that you know is invalid?
And where does your -1 come from?
@ManuelP -1 as for invalid
@ManuelP well, i mean we can easily use a set to check if its already been added to avoid duplicate add, i guess this is not the case that this question considered, but is good to discuss in a interview, since it was put it as a Note:
- Invalid cases don't need to be handled. If the caller violates the contract, they can't blame the callee.
- If you wanted to check for validity, you' have to check for a lot more.
- The problem doesn't say anything about -1. Looks like you invented that yourself.
- It's a bad invention, since -1 is a possible valid result (i.e., the result of a valid input). I just checked, there actually is a test case where the result is -1.
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.