Advertisement
Guest User

Untitled

a guest
Oct 24th, 2014
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.47 KB | None | 0 0
  1. import java.util.ArrayList;
  2. import java.util.Collections;
  3. import java.util.HashSet;
  4. import java.util.List;
  5.  
  6. public class AuntUncle {
  7.     public String[] list(String[] parents, String target) {
  8.         String targetFather = null;
  9.         String targetMother = null;
  10.         HashSet<String> grandparents = new HashSet<String>();
  11.         HashSet<String> parentSet = new HashSet<String>();
  12.         List<String[]> splitParents = new ArrayList<String[]>();
  13.         List<String> siblings = new ArrayList<String>();
  14.        
  15.         // for loop through the strings of parents to split them
  16.         // into int arrays of [parent1, parent2, child]
  17.        
  18.        
  19.        
  20.         // for loop over the split families to look for the target's family
  21.         // if you've found the target's family, save the parents of that family string array
  22.         // as the targetFather and targetMother
  23.        
  24.        
  25.        
  26.         // for loop over the split families to find the families of targetFather/targetMother
  27.         // if you find a family where the targetFather/Mother are the children
  28.         // save those four parents as part of the grandparents set
  29.        
  30.        
  31.        
  32.         // for loop over the split families one last time
  33.         // if you encounter a family where parent1 or parent2 is in the grandparents set
  34.         // the child of that family must be a sibling of targetFather/Mother
  35.         // but add an if condition to avoid counting targetFather/Mother as siblings of themselves
  36.        
  37.        
  38.        
  39.         // sort alphabetically
  40.        
  41.        
  42.        
  43.         // convert the ArrayList of sibling's you've been adding to an array to return
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement