↳
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
↳
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
↳
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
↳
SC calculated the correct probability of getting WRONG socks if allowed to ONLY take 2 single socks from a mix of 19 single grey and 25 single black socks. The correct calculation is 942/1892 is the actual chance of getting a pair of either colour (don't care if they match the suit - since I don't know what colour suit I'm wearing, as it's dark, just that they match each other). This is 49.7%. Since this is less than an even bet, it is probably time to look for a creative solution (after providing the correct answer of course). I'm disappointed none of you checked the maths before providing the standard '3 socks make a pair' response - which I prefer anyway - or the selection of brilliant lateral thinking responses. (My wife kindly pairs my socks as I' colour blind anyway - so they always match each other - but seldom match my clothing.) Tara has obviously not read the question - 3 grey or 3 black socks does provide a matching pair. If I want a matching pair which ALSO matches my suit - then I need to be allowed more socks - 21 if I want a black pair, 27 if I want a grey pair - or of course 27 in the worst case if I don't know what suit I'm wearing, and it happens to be grey. Moins
↳
There are (25 choose 2) unique combinations of black + (19 choose 2) unique combinations of grey out of a total of ((25+19) choose 2) unique combinations. 25 choose 2 = 25! / (2! * (25 - 2)!) = 300 19 choose 2 = 19! / (2! * (19 - 2)!) = 171 44 choose 2 = 44! / (2! * (44 - 2)!) = 946 (300 + 171) / 946 = 0.4979 = 49.79% probability, same as concluded by Mickey's correction of SC. Sorry 2easy, time to brush up on your probabilities. Moins
↳
You could give the precise answer as above (be SC) or, more simply, you could tell them you grab three socks as two of them will match for sure. Moins
↳
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
↳
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
↳
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
↳
hey buddy can you please contact me at vishuvashishth3@gmail.com
↳
hey..can someone plz help me out with some expected questions/word puzzles in d 4rth round? i have my interview tomorrow.. My id is aliyashaista@gmail.com Moins
↳
performance testing is a subset of performance engineering, which is focused on addressing performance issues in the design and architecture of a software product.stress testing evaluates the behavior of an application beyond peak load and normal conditions. Moins
↳
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
↳
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