APT: AuntUncle

Class

public class AuntUncle { public String[] list(String[] parents, String target) { // fill in code here } }

Problem Statement

You are writing software to help someone understand their very complicated family. Your task is to determine all aunts and uncles of a given person. An aunt or uncle of a person is defined as a sibling of that person's parent. Two people are siblings if they have one or more parents in common.

Create a class AuntUncle that contains a method list which receives a String[], with each element containing a record of a person's birth - in the form of "PARENT1 PARENT2 CHILD" (quotes for clarity only), and a single String with the target person's name, and returns a String[] of all aunts and uncles for that target person, sorted alphabetically.

Notes and Constraints

Examples

  1. 
    parents = {"JOE JANE ROB"}
    target = "ROB"
    
    Returns:  {}
    
    
    Target "ROB"'s parents do not have parents, let alone siblings. "ROB" has no uncles or aunts.

  2. 
    parents = {"JOE MARY FRANK", "BOB JANE MARTHA", "FRANK MARTHA ROB", 
               "BOB AMANDA TROY"}
    target = "ROB"
    
    Returns: {"TROY"}
    
    
    Target "ROB"'s parent "MARTHA" has a parent "BOB" who has a child other than either of "ROB"'s parents. This child is named "TROY", and must be "ROB"'s Uncle (or Aunt).

  3. 
    parents = {"HECTOR DANA ROB", "ROB MARY JOE", "JOE MARY FRANK"}
    target = "FRANK"
    
    Returns:{}
    
    
    Target "FRANK"'s parent "MARY" is also his parent "JOE"'s parent. Be careful you don't think "FRANK" is his own Uncle (or Aunt).

  4. 
    parents = {"A B E", "C D F", "E F G", "A P Z", "B P Y", "C P X", "D P W", 
               "A B V", "B C U", "A C T", "B D S", "A D R", "B C Q"}
    target = "G"
    
    Returns: {"Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"}
    
    
    Note that the answer is sorted alphabetically.