Amazon Interview Question
Software Engineer in TestsAssume there are n statements
All statements can't be wrong else last statement will become true. This contradicts itself(because it says no statement is correct).
All statements are contradicting each other. Hence only 1 statement can be right. That means n-1 statements are wrong.
This is exactly what (n-1)th statement suggests. Hence all statements except (n-1)th statement are wrong.
I know its tough to understand but try simple example when n=5
1) 1 statement is false
2) 2 statements are false
3) 3 statements are false
4) 4 statements are false
5) 5 statements are false
Statement 5) cannot be true. Statement 1) cannot be true. We will find that only statement 4) can be correct
Can some one explain why statements 1,2,3 are false ?
I understand the reasoning for statement 5 but I am unable to extend the logic for statements 1,2,3
because if 1 is true, that means 2,3,4 must all be true (since we have already known 5 to be false). But this can't be the case since for 2 to be true, there must be 2 false statements. Same with 3 and 4. So 1 is obviously wrong.
Using the same argument, repeat it for 2 and 3, and you will deduce both are also false.
Anyway, perfect answer Avinash :)
"All statements are contradicting each other. Hence only 1 statement can be right. That means n-1 statements are wrong.
This is exactly what (n-1)th statement suggests. Hence all statements except (n-1)th statement are wrong."
Refer this:
- Alice October 24, 2009http://discuss.joelonsoftware.com/default.asp?interview.11.454352.10