Booking.com Interview Question for Android Engineers


Team: Android
Country: Netherlands
Interview Type: Phone Interview




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

A = {2, 5, 3, 2, 8,1} 
B = {7, 9, 5, 2, 4, 10, 10} 
C = {6, 7, 5, 5, 3, 7}
s1=A&B&C
s2=A&B
s3=A&C
s4=B&C
s=s1|s2|s3|s4
print(s)

- jlokhande46 June 15, 2019 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Complexity seems very bad for this solution. I would just use a hash table and scan all array once.
key :- element and value will be set of id {}
for example, in above case hash table entry for 2 will be 2 -> { A, B} since its seem in two arrays.
Later just scan hash table and get result where value size is atleast 2.

- code reviewer June 18, 2019 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

nice sol ...but still that wont work if you have multiple duplicates
A = {2, 1,1,1,1}
B = {1,1,1, 10}
C = {1,1,1, 10, 7}
output should be {1,1,1}

- Anonymous June 18, 2019 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

public void extractArray(int[] a, int[] b, int[] c){
List<Integer> list = new ArrayList<Integer>();
for(int i = 0; i< a.length; i++){
int valueSearched = a[i];
System.out.println(valueSearched);
System.out.println("Loop1-----------");
boolean flag1 = false;
boolean flag2 = false;
for(int j =0; j<b.length;j++){
System.out.println(b[j]);
System.out.println("Loop2-----------");
if(!list.contains(valueSearched) && valueSearched == b[j]){
list.add(valueSearched);
break;
}
}

for(int k=0;k<c.length;k++){
System.out.println(c[k]);
System.out.println("Loop3-----------");
if(!list.contains(valueSearched) && valueSearched == c[k]){
list.add(valueSearched);
break;
}
}

}
System.out.println(Arrays.toString(list.toArray()));

}

- Anonymous June 15, 2019 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

{

public void extractArray(int[] a, int[] b, int[] c){
List<Integer> list = new ArrayList<Integer>();
for(int i = 0; i< a.length; i++){
int valueSearched = a[i];
System.out.println(valueSearched);
System.out.println("Loop1-----------");
boolean flag1 = false;
boolean flag2 = false;
for(int j =0; j<b.length;j++){
System.out.println(b[j]);
System.out.println("Loop2-----------");
if(!list.contains(valueSearched) && valueSearched == b[j]){
list.add(valueSearched);
break;
}
}

for(int k=0;k<c.length;k++){
System.out.println(c[k]);
System.out.println("Loop3-----------");
if(!list.contains(valueSearched) && valueSearched == c[k]){
list.add(valueSearched);
break;
}
}

}
System.out.println(Arrays.toString(list.toArray()));

}

}

- Anonymous June 15, 2019 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Step 1) Sort all the n arrays in ascending order and create a set named "duplicate"
Step 2) create a heap with the first elements i.e. the smallest, of all the arrays.
Step 3) poll out the first 2 elements from heap and also insert 2 elements from the respective 2 arrays, who's elements are taken out of the heap.
Step 4) if the elements are same put it in the set. Throw away the first element, get the next element from heap and compare the current 2 elements and put in the set if same. Also insert another element from the respective array. Continue the process.

- s100banerjee June 30, 2019 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Integer[] A = {2, 5, 3, 2, 8, 1};
Integer[] B = {7, 9, 5, 2, 4, 10, 10};
Integer[] C = {6, 7, 5, 5, 3, 7};

List<Integer> AA = new ArrayList<>(Arrays.asList(A));
List<Integer> BB = new ArrayList<>(Arrays.asList(B));
List<Integer> CC = new ArrayList<>(Arrays.asList(C));

HashSet<Integer> total = new HashSet<>();

total.addAll(AA);
total.addAll(BB);
total.addAll(CC);

for (Integer s : total) {
if( (AA.contains(s) && BB.contains(s))){
System.out.println(s +" Present in arrays A & B");

} else if( (BB.contains(s) && CC.contains(s))){
System.out.println(s +" Present in arrays B & C");

} else if( (CC.contains(s) && AA.contains(s))){
System.out.println(s +" Present in arrays C & A");

}
}

- senthilb4u2005 July 01, 2019 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

package booking;

import java.util.*;

public class ConstructArray {

static void makeArr(int[] a, int[] b, int[] c) {
HashMap<Integer, Integer> map = new HashMap<>();
Integer[]A = removeDuplicates(a);
Integer[]B = removeDuplicates(b);
Integer[]C = removeDuplicates(c);

System.out.println(Arrays.toString(A));
System.out.println(Arrays.toString(B));
System.out.println(Arrays.toString(C));

for (int i : A)
map.put(i, 1);

for (int j : B) {
if (map.containsKey(j))
map.put(j, 1 + map.get(j));
else
map.put(j, 1);
}

for (int k : C) {
if (map.containsKey(k))
map.put(k, 1 + map.get(k));
else
map.put(k, 1);
}

for (int key : map.keySet()) {
if (map.get(key) > 1)
System.out.print(key);
}

}

static Integer[] removeDuplicates(int a[]){
HashSet<Integer> set = new HashSet<>();
for (int i:a)
set.add(i);
return set.toArray(new Integer[set.size()]);
}

public static void main(String[] args) {
int[] A = {2, 5, 3, 2, 8, 1};
int[] B = {7, 9, 5, 2, 4, 10, 10};
int[] C = {6, 7, 5, 5, 3, 7};

makeArr(A,B,C);
}

}

- eng.mahmoudramadan2012 July 14, 2019 | 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