Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
br80 authored Jun 11, 2019
1 parent bfa67a4 commit fd2fce0
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions projects/ancestor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,19 @@ Suppose we have some input data describing a graph of relationships between pare

For example, in this diagram and the sample input, 3 is a child of 1 and 2, and 5 is a child of 4:

```
10
/
1 2 4 11
\ / / \ /
3 5 8
\ / \ \
6 7 9
```

Write a function that, given the dataset and the ID of an individual in the dataset, returns their earliest known ancestor – the one at the farthest distance from the input individual. If there is more than one ancestor tied for "earliest", return the one with the lowest numeric ID. If the input individual has no parents, the function should return -1.

```
Example input
6
Expand All @@ -33,6 +37,8 @@ Example input
10 1
Example output
10
```

Clarifications
The input will not be empty.
There are no cycles in the input.
Expand Down

0 comments on commit fd2fce0

Please sign in to comment.