# Questions d'entretiens - Quality engineer

# 17 k

Questions d'entretien pour Quality Engineer partagées par les candidats## Principales questions d'entretien

### There are three boxes, one contains only apples, one contains only oranges, and one contains both apples and oranges. The boxes have been incorrectly labeled such that no label identifies the actual contents of the box it labels. Opening just one box, and without looking in the box, you take out one piece of fruit. By looking at the fruit, how can you immediately label all of the boxes correctly?

46 réponses↳

Swaz answer is almost correct however it does not work in all scenarios. lets assume: box 1 is labelled Oranges (O) box 2 is labelled Apples (A) box 3 is labelled Apples and Oranges (A+O) and that ALL THREE BOXES ARE LABELLED INCORRECTLY" Pick a fruit from box 1, 1) if you pick an Orange: - box 1's real label can only be O or A+O - box 1's current label is O - since ALL LABELS ARE INCORRECT then box 1's real label can not be O - box 1's new label should then be A+O by elimination - since ALL LABELS ARE INCORRECT - box 2's label is changed to O - box 3's label is changed to A - SOLVED 2) if you pick an Apple: - box 1's real label can only be A or A+O - box 1's current label is O - since ALL LABELS ARE INCORRECT then box 1's real label can not be O - this still leaves us with the choice between label A and label A+O - which would both be correct - FAILURE Solution: The trick is to actually pick a fruit from the A+O labeled box Pick a fruit from box 3: 1) if you pick an Orange: - box 3's real label can only be O or A - box 3's current label is A+O - since ALL LABELS ARE INCORRECT then box 3's real label can not be A+O - box 3's new label should then be O by elimination - since ALL LABELS ARE INCORRECT - box 1's label is changed to A - box 2's label is changed to A+O - SOLVED 2) if you pick an Apple: - box 3's real label can only be O or A - box 3's current label is A+O - since ALL LABELS ARE INCORRECT then box 3's real label can not be A+O - box 3's new label should then be A by elimination (not O) - since ALL LABELS ARE INCORRECT - box 1's label is changed to A+O - box 2's label is changed to O - SOLVED Moins

↳

All the three boxes are names incorrectly. SO the bax lebeled Apples+Oranges contains only Oranges or Only Apples. Pick one fruit from it. If it is Orange then lebel the box as Orange. So the box lebeled Oranges contains Apples and the remaining contains both. Moins

↳

It's easier to draw it out. There are only 2 possible combinations when all labels are tagged incorrectly. All you need to do is pick one fruit from the one marked "Apples + Oranges". If it's Apple, then change "Apple + Orange" to "Apple" The "Apple" one change to "Orange" The "Orange one change to "Apple + Orange" If it's Orange, then change "Apple + Orange" to "Orange" The "Apple" one change to "Apple + Orange" The "Orange" one change to ""Apple" Moins

### A dwarf-killing giant lines up 10 dwarfs from shortest to tallest. Each dwarf can see all the shortest dwarfs in front of him, but cannot see the dwarfs behind himself. The giant randomly puts a white or black hat on each dwarf. No dwarf can see their own hat. The giant tells all the dwarfs that he will ask each dwarf, starting with the tallest, for the color of his hat. If the dwarf answers incorrectly, the giant will kill the dwarf. Each dwarf can hear the previous answers, but cannot hear when a dwarf is killed. What strategy should be used to kill the fewest dwarfs, and what is the minimum number of dwarfs that can be saved with this strategy?

21 réponses↳

Think broadband communication. Exploit the capabilities of the communications medium. A minimum of nine dwarves can be saved based on the information provided in the original post I viewed. The strategy is for each dwarf to employ the expected language to communicate the color of their own hat to the giant, while simultaneously employing a vocal pitch protocol to indicate the color of the hat of the dwarf in front of him, high pitch for white and low pitch for black. The original post, indicates the dwarves may collude prior to the distribution of hats, so there is opportunity to negotiate such a simple broadband communication protocol. The tallest dwarf only has a 50/50 chance since the number of black and white hats in play is not known (rhetorical question, what are the odds the tallest dwarf's hat is black if he turns to find that all nine hats in front of him are white? I don't know, but odds are high that the giant is a sadistic bloke). The original post I viewed is here. http://www.businessinsider.com/toughest-job-interview-questions-2013-7#a-dwarf-killing-giant-lines-up-10-dwarfs-from-shortest-to-tallest-each-dwarf-can-see-all-the-shortest-dwarfs-in-front-of-him-but-cannot-see-the-dwarfs-behind-himself-the-giant-randomly-puts-a-white-or-black-hat-on-each-dwarf-no-dwarf-can-see-their-own-hat-the-giant-tells-all-the-dwarfs-that-he-will-ask-each-dwarf-starting-with-the-tallest-for-the-color-of-his-hat-if-the-dwarf-answers-incorrectly-the-giant-will-kill-the-dwarf-each-dwarf-can-hear-the-previous-answers-but-cannot-hear-when-a-dwarf-is-killed-the-dwarves-are-given-an-opportunity-to-collude-before-the-hats-are-distributed-what-strategy-should-be-used-to-kill-the-fewest-dwarfs-and-what-is-the-minimum-number-of-dwarfs-that-can-be-saved-with-this-strategy-11 Moins

↳

What is the minimum number of dwarfs that can be saved with this strategy? 9 First of all, let's numerate the dwarfs as N1, N2, N3, etc. with N10 being the tallest. Now, N10 will state the color of N9 as his own answer, "My hat is WHITE". Based on this answer, N9 will state his color with a positive statement if the color of N8 is the same as his, "My hat is WHITE". Based on N8's answer, N8 knows that his color is WHITE, now, he will state his color depending on N7. Let's say N7 is black, so N8 will state, "My hat is NOT BLACK". N7 knows that his color is BLACK, but N6 is white, so he will use a negative statement, "My hat is NOT WHITE" and so on. Full example: N10 = BLACK N9 = WHITE N8 = WHITE N7 = BLACK N6 = WHITE N5 = WHITE N4 = WHITE N3 = BLACK N2 = BLACK N1 = WHITE N10: My hat is WHITE (Dies) N9 = My hat is WHITE N8 = My hat is NOT BLACK N7 = My hat is NOT WHITE N6 = My hat is WHITE N5 = My hat is WHITE N4 = My hat is NOT BLACK N3 = My hat is BLACK N2 = My hat is NOT WHITE N1 = My hat is WHITE N10 will have a 50/50 chances of survival... I'm sorry N10, I couldn't save you :'( Moins

↳

the question does not mention that there will be equal number of white and black hats ! Moins

### Find the union of two strings?

14 réponses↳

public static void UnionOfStrings() { String s1 = "XYZ"; String s2 = "YZOP"; String s3 = s1.concat(s2); char ch[] = s3.toCharArray(); Set setChars = new TreeSet(); for(char c : ch) { setChars.add(c); } System.out.println(setChars.toString()); } Output : [O, P, X, Y, Z] Moins

↳

public static void IntersectionOfStrings() { String s1 = "XYZYYP"; String s2 = "YZOPP"; Set setChars = new TreeSet(); char c[] = s1.toCharArray(); for(char x : c) { if(s2.indexOf(x)!=-1) { setChars.add(x); } } System.out.println(setChars.toString()); } OUTPUT : [P, Y, Z] Moins

↳

public static void IntersectionOfStrings() { String s1 = "yybbb78"; String s2 = "y7"; if(s1.length() > s2.length()) intersect(s1,s2); else intersect(s2,s1); } public static void intersect(String first, String second) { Set setChars = new TreeSet(); char c[] = first.toCharArray(); for(char x : c) { if(second.indexOf(x)!=-1) { setChars.add(x); } } System.out.println(setChars.toString()); } Moins

### Draw a bridge and you have three people trying to cross? Seriously&gt;

12 réponses↳

I actually had an interview with Clearleap yesterday and I can tell you that above comments are not true. Interview process was very professional. Problem solving questions were quite interesting and I enjoyed them! Moins

↳

Unfortunately, your response is quite immature and therefore I withdraw myself from this conversation. Moins

↳

4 people actually (you missed the requirement). Looks like you did not pay attention during the interview. These types of questions are designed to figure out your: a) Problem solving skills b) Creativity c) Ability to work under pressure And most of all to observe your thought process. But in your Senior QA Engineer role you should have know about that already, right? Moins

### Write a function in any language that will print "AN" if a number is divisible by 8, "ANIM" if divisible by 16 and "ANIMAL" if divisible by 32.

11 réponses↳

Good work. I checked your code and it runs. This is a variation on the classic FizzBuzz coding question. One suggestion: You can simplify your code by printing the user prompt in the input function. # i = input("Enter a number or press Q to quit:") Another suggestion: Make the letter "q" case insensitive by passing the ".lower()" method after your input string # i = input("Enter a number or press Q to quit:").lower() One thing: You don't need the following if clause which I've commented out. This condition is already checked and handled outside of the try block. """ try: n = int(i) # if i == "q": # print("Goodbye!") """ Moins

↳

Use string builder to improve the run time.

↳

public static String printAnimal(int num) { if (num >= 8 && num = 16 && num = 16 && num < 32) { if (num % 32 == 0) { return "ANIMAL"; } } return "Number Not Divisible by 8"; } Moins

### From a given list of array (Not sorted) find the second largest value Find the prime numbers from the given list of array (1 -100) Test plan for Amazon login screen

10 réponses↳

The second question is pretty simple, and it does relate back to test cases. Think of every number as a different state of a program, and proceed as follows: Create a new list to house all your prime numbers. Add 2, 3, 5, and 7 to it. Then, iterate through your list. If the number you're looking at can be taken to 0 with a modulus of 2, 3, 5, or 7, ignore it. If passes all those tests, add it to your list of primes. This will give you a list of all prime numbers between 0 and 100. The trick is that if you know the largest number in the list, you can find all prime numbers in the list just by knowing all prime numbers less than the square root of your largest number (in this case, sqrt(100) = 10 and we look at 2, 3, 5, and 7. If the list was up to 121, we'd look at 2, 3, 5, 7, and 11.) This both gets you your answer AND minimizes the runtime of your program. I don't have any fancy tricks for the first question, but given that sorting is often time-consuming I would go with something like this: 1: Iterate through the list. Use two variables, a "largest" and "second largest." These two should start at 1 and 0 respectively. 2: With every number N, compare the value of N to "largest" and "second largest." 3: If N is larger than "second largest" and smaller than "largest," replace "second largest" with N. 4: If N is bigger than both "largest" and "second largest," then make "second largest" the value of "largest" and make the value of "largest" equal to N. This is very much a "brute force" solution. It may not be the best, but like I said - I don't know any special tricks for this problem. Moins

↳

x = [10,21,2,3,4,5,6,7,8,9,12,45,67,88,888,4,4,5,3,3,45,37,34,6,777] y = [0,0] for(i= 0 ;i y[0] ){ y[0]= x[i] } } for(i= 0 ;i y[1] && x[i] !== y[0]){ y[1]= x[i] } } console.log(y[1]) Moins

↳

var foo = []; var bar = [] for (var i = 1; i <= 100; i++) { foo.push(i); } for (var i = 0; i < foo.length ; i++) { if(isPrime(foo[i])){ bar.push(foo[i]) } } function isPrime(n){ if(n<=1){ return false} if(n<=3){ return true} if(n === 5 || n === 7) { return true} if(n % 2 === 0 || n % 3 === 0 || n % 5 === 0 || n % 7 === 0) {return false} return true; } console.log(bar) Moins

### Reverse a string

9 réponses↳

def main(): str=input("Enter a string") print(str[: : -1]) main()

↳

Javascript const foo = "bar"; const baz = foo.split('').reverse().join(''); :^) Moins

↳

How about this: for(int index = 0; index < input.length() ; index++ ) { output.insert(0, input.charAt(index)); } Moins

### find the largest sum of consecutive integers in an array

8 réponses↳

int consecutive_Sum (int arr[]){ int prev =0,temp_sum=0,ret_sum=0,i=0; for(i=0;arr[i]!='\0';i++){ if(arr[i] == (prev+1)){ temp_sum += arr[i]; prev = arr[i]; if(ret_sum < temp_sum){ ret_sum = temp_sum; } }else{ temp_sum = arr[i]; prev = arr[i]; } } return ret_sum; } Moins

↳

def maxSubArray(self, nums: List[int]) -> int: result = -sys.maxsize sum_ = 0 for i in range(0, len(nums)): sum_ = max(sum_ + nums[i], nums[i]) result = max(result, sum_) return result Moins

↳

a = [29, -22, 0.22, 0, 999, -22] a.sort() max_a = a[-1] print(max_a)

### input string = aabbbccccaaa, maintain the insertion order and output should be a2b3c4a3

8 réponses↳

//input string = aabbbccccaaa, maintain the insertion order and output should be a2b3c4a3 public class Test { public static void process(String mystring) { StringBuilder sb = new StringBuilder(); char[] mychar = mystring.toCharArray(); int count = 1; for(int i=0; i< (mychar.length)-1;i++) { System.out.println("mychar[p1]: "+mychar[i]+" mychar[p2]: "+mychar[i+1]); if(mychar[i] == mychar[i+1]) { count = count+1; System.out.println("count: "+count); } else { sb.append(mychar[i]); sb.append(count); count = 1; } if(i==(mychar.length)-2) { sb.append(mychar[i+1]); sb.append(count); } } System.out.println(sb.toString()); } public static void main(String[] args) { process("aabbbccccaaa"); process("ggggyyynnnkkkkkk"); process("aabbcccdef"); process("abcdefghj"); } } Moins

↳

a = "aaabbbaaaa" i=0 j=0 fnl_result ="" for item in a: if i== 0: temp = item j = j+1 elif item == temp: j = j+1 elif item!=temp: fnl_result = fnl_result+str(temp)+str(j) j=1 temp = item i=i+1 fnl_result = fnl_result+str(temp)+str(j) print fnl_result #output = a3b3a4 Moins

↳

public class Stringoupt { int count =0; void outputString(String str){ char st = str.charAt(0); for(int i=0;i Moins

### How to find a special weight ball from 8 balls while other 7 have the same weight with a balance? (all same color, shape etc.) Trick is that you don't know if the special ball is lighter or heavier.

7 réponses↳

a. Divide balls into sets of 3,3,2 b. Compare 3 & 3 i. If equal, compare the other 2 balls against each other. 1) If 1 is heavier then compare it any one ball in set of 6 other balls a) If both are equal, the ball left is the special ball (lighter) b) If the ball is heavier then it is the special ball (heavier) ii. If not equal, take the one which is heavier and compare any 2 balls 1) If both are equal, Compare one of them with the other one left a) If they are also equal, go to next step iii. b) If the new ball is heavier, then it is special ball (heavier) 2) If 1 is heavier, then it is special ball (heavier) iii. If not equal, and all the balls in other set are equal, compare any 2 balls 1. If both are equal, the ball left is the special ball (lighter) 2. If the ball is lighter, then it is the special ball (lighter) Moins

↳

Don't you read the question? You don't know if the special ball is heavier or lighter! Moins

↳

Well I guess hcb and charlie won't pass the interview :( Let's say we have balls numbered 1 to 8. 1) Weight 1,2,3 against 4,5,6. If balanced the special ball in one of 7 or 8, goto (2), otherwise record the heavier groupe (let's say 1,2,3 is heavier) and goto (3) 2) Weight 1 against 7, if balanced the special ball is 8, else 7. 2 steps in this case 3) Weight 1,2 against 3,4, if balanced the special ball is one of 5 or 6, goto step (4), otherwise record the heavier groupe (let's say 1,2 is heavier) and goto (5) 4) Weight 1 against 5, if balanced the special ball is 6, else 5. 3 steps in this case 5) Now we consider if the special ball is heavier or lighter. If it's lighter, we check the result that 1,2,3 is heavier than 4,5,6 and 1,2 is heavier than 3,4, and we can say 4 would be the lighter ball because all other balls have the same weight. If it's the special ball is heavier, we can say the special ball is one of 1 or 2, then we can just weight 1 against 2 and find the heavier one. 3 steps in this case. Moins