Amazon Interview Question for SDE1s


Country: United States
Interview Type: Phone Interview




Comment hidden because of low score. Click to expand.
0
of 0 vote

Public class Dog
{
   boolean gender;
   List<Dog> childrens = new ArrayList<Dog>();
   Dog sprouce;
   Pedigree pedigree = Pedigree.Unknown;
   int age;
   List<String> characteristics = new ArrayList<String>();
}

Public enum Breed
{
   PAMERIAN("white", "short", "sweet"),
   ALSESIAN("dark", "huge", "dangerous"), 
   DOVERMAN("huge", "faithful"), 
   UNKNOWN();
   
   public Breed(String... breedCharacterstics)
   {
      m_breedCharacterstics = Arrays.asList(breedCharacterstics);
   }
   
   List<String> m_breedCharacterstics = new ArrayList<String>();
}

Public enum PedigreeType
{
   PURE, MIXED, UNKNOWN;
}

Public interface Pedigree
{
    PedigreeType pedigreeType = PedigreeType.UNKNOWN;
}

Public interface PurePedigree extends Pedigree
{
   Breed breed = Breed.UNKNOWN;
   pedigreeType = PedigreeType.PURE;
}

Public interface MixedPedigree extends Pedigree
{
   pedigreeType = PedigreeType.MIXED;
   Pedigree motherPedigree;
   Pedigree fatherPedigree;
}

Public class DogsInBreederCamp
{
   Lst<Dog> admittedDogs = new ArrayList<Dog>();
   
   public List search(SearchCriteria criteria)
   {
   }
}

Public class SearchCriteria
{
  List<String> characterstics;
  Breed breed;
  PedegreeType;
}

- Anonymous December 19, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Please ignore earlier one.. check this one

Public class Dog
{
   String id;
   boolean genderFemale;
   List<Dog> childrens;
   Dog mother;
   Dog father;
   Pedigree pedigree;
   int age;
   List<String> characteristics;
   
   public boolean matches(SearchCriteria criteria)
   {
      boolean matches = true;
      // check pedigree
      if( criteria.pedigree != null &&
         !pedigree.equals(criteria.pedigree)
      {
         matches = false;
      }
      
      // check dog characterstics
      for(String c : criteria.characterstics)
      {
         // check dog characteristics
         
         // check breed characterstics
      }  
      
      return matches;
         
   }
}

Public enum Breed
{
   PAMERIAN("white", "short", "sweet"),
   ALSESIAN("dark", "huge", "dangerous"), 
   DOVERMAN("huge", "faithful"), 
   UNKNOWN();
   
   public Breed(String... characterstics)
   {
      breedCharacterstics = Arrays.asList(characterstics);
   }
   
   List<String> breedCharacterstics = new ArrayList<String>();
}

Public class Pedigree
{
}

Public class PurePedigree extends Pedigree
{
   Breed breed;
}

Public class MixedPedigree extends Pedigree
{
   Pedigree motherPedigree;
   Pedigree fatherPedigree;
}

Public class DogsInBreederCamp
{
   List<Dog> admittedDogs = new ArrayList<Dog>();
   Map<String, Dog> allDogs = new HashMap<String, Dog>();
   
   public List search(SearchCriteria criteria)
   {
      List<Dog> results = new ArrayList<Dog>();
      for(Dog dog : allDogs.values())
      {
         if(dog.matches(criteria))
         {
            results.add(dog);
         }
      }
      return results;
   }
}

Public class SearchCriteria
{
  List<String> characterstics;
  Pedigree pedigree;
}

- Anonymous December 19, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

can anyone please explain me the solution to this question. I am finding it difficult

thanks

- lks December 25, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

can anyone help with the design solution for this question

- lks December 27, 2013 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More