Work in HR or Recruiting?
eBay
www.ebay.com San Jose, CA 5000+ Employees
Work in HR? Complete Your Profile

58 interview experiences Back to all eBay Interview Questions & Reviews

Interview Question for Software Engineer at eBay:
Sep 2, 2012

write code to do the reverse mapping from phone number to its all possible combination of letters. Ex- if dialed 12 then all possible combinations will be ad, ae, af, bd, be, bf, cd, ce, cf and so on...


Tags: technical, analytical, algorithm
Add Tags [?]

See more for this eBay Software Engineer Interview

Helpful Question?  
Yes | No
Inappropriate?

Answers & Comments (2)

Sep 2, 2012

by Interview Candidate:

interviewer was not at all helpful, seems like she didn't know what I was talking about
Helpful Answer?  
Yes | No
Inappropriate?

Nov 12, 2012

by Anonymous:

This is a permutation problem. Each number maps to 3 or 4 letters, except zero, which does not map to anything.
Create map of each number to an array of characters: ncMap.get(1) returns {A,B,C}
Let int[] input be the phone number.

int print(int[] input, int inputStartPos, HashMap<Integer,Character[]> ncMap, List<Character> accumulator){
  if(input == null || inputStartPos < 0 || inputStartPos > input.length-1) return -1;
  Character[] chars = ncMap.get(input[inputStartPos]);
  if(inputStartPos == input.length-1){
    for(int i = 0; i < chars.length; i++){
      printAccumulator(accumulator); // print all chars we have so far.
      print(chars[i]);
    }
    return 0; // success
  }
  else {
    for(int i = 0; i < chars.length; i++){
      accumulator.append(chars[i]);
      print(input, inputStartPos++, ncMap, accumulator);
    }
  }
}
Helpful Answer?  
Yes | No
Inappropriate?

To comment on this question, Sign In with Facebook or Sign Up

Tags are like keywords that help categorize interview questions that have something in common.