I had an initial Technical round with the Manager and a team member about my work experience and resume walk through and no coding, then I had the second round to asses my coding skills, and below are the questions.
PS: I gave eBay interview twice in the last 3 months and I was asked the dictionaryWords problem in both the interviews
/* String[] dictionaryWords = {"cd", "f", "kl","ebay","e",”bay”};
public static void main(String[] args) {
System.out.println(query('a')); // return false
System.out.println(query('a')); // return false
System.out.println(query('b')); // return false
System.out.println(query('c')); // return false
System.out.println(query('d')); // return true, because 'cd' is in the wordlist
System.out.println(query('e')); // return true because 'e' is in the wordlist
System.out.println(query('f')); // return true, because 'f' is in the wordlist
System.out.println(query('g')); // return false
System.out.println(query('h')); // return false
System.out.println(query('i')); // return false
System.out.println(query('j')); // return false
System.out.println(query('k')); // return false
System.out.println(query('l')); // return true, because 'kl' is in the wordlist
System.out.println(query('e')); // return true because 'e' is in the wordlist
System.out.println(query('e')); // return true because 'e' is in the wordlist
System.out.println(query('b')); // return false
System.out.println(query('a')); // return false
System.out.println(query('y')); // return true because 'bay' is in the wordlist
a a
a a,aa
b ab,aab
c aabc,abc,bc
d aabcd,abcd,bcd,cd
*/import java.io.;
import java.util.;
/*
class Solution {
private static StringBuilder input = new StringBuilder();
private static String[] dictionaryWords = {"cd", "f", "kl","ebay","e","bay"};
private static List dictionary = new ArrayList<>(Arrays.asList(dictionaryWords));
private static List keywords = Arrays.asList("Buffered","BufferedOutput","BufferedOutputStream");
private static Map<String,String> map = new HashMap();
static {
map.put("B","Buffered");
map.put("BO","BufferedOutput");
map.put("BOS","BufferedOutputStream");
map.put("ABOS","ArrayBufferedOutputStream");
}
public static void main(String[] args) {
System.out.println(query('a')); // return false
System.out.println(query('a')); // return false
System.out.println(query('b')); // return false
System.out.println(query('c')); // return false
System.out.println(query('d')); // return true, because 'cd' is in the wordlist
System.out.println(ideAutocomplete("Buffered"));
System.out.println(ideAutocomplete("BO"));
System.out.println(ideAutocomplete("Bo")); }
private static boolean query(char c){
List words = new ArrayList<>();
input.append(c);
for(int i=0; i< input.length(); i++)
words.add(input.substring(i,input.length()));
System.out.println("words "+ words);
Set<String> result = dictionary.stream().distinct()
.filter(words::contains)
.collect(java.util.stream.Collectors.toSet());
return result.size() > 0;
}
public static List<String> ideAutocomplete(String word){
List<String> result = new ArrayList<>();
for(Map.Entry<String,String> entry : map.entrySet()){
if(entry.getKey().startsWith(word)) result.add(entry.getValue());
if(entry.getValue().startsWith(word)) result.add(entry.getValue());
}
return result;}
}
/*
Buffered B
BufferedOutput BO
BufferedOutputStream BOS
Type B all 3 should display
When I say Buffered, all 3 should display?..
BO only BufferedOutput and BufferedOutputStream should be displayed
BOP only BufferedOutputStream should be displayed
Basically free text match exactly starting of the word…capitalized should match capital letter in word list
*/