In a row of 40 students, Rahul is 12th from the left. Neha is 4th to the right of Rahul. What is Neha's position from the right end?
25th from the right. Neha is 12 + 4 = 16th from the left. Position from the right = total - position from the left + 1 = 40 - 16 + 1 = 25.
Explain it simply
In a line, a person's place from the left and from the right always add up to the total plus one, because the person is counted from both sides. Think of a queue at an IRCTC counter: if you are 3rd from the front in a queue of 10, you are 8th from the back, and 3 + 8 = 11.
Example
Question: 40 students. Rahul is 12th from the left. Neha is 4th to the right of Rahul. Neha from the right?
- Neha from the left = 12 + 4 = 16.
- From the right = 40 - 16 + 1 = 25.
Check: 16 + 25 = 41 = 40 + 1.
Related question: how many students sit between Rahul and Neha? Positions 13, 14 and 15, so 3 students (one fewer than the gap of 4).
const total = 40, left = 12 + 4;
console.log(total - left + 1); // Output: 25
console.log(16 - 12 - 1); // Output: 3What to say in the interview
"Neha is 16th from the left. Left rank plus right rank is total plus one, so she is 40 minus 16 plus 1, which is 25th from the right."
Common mistakes
- Forgetting the +1 and answering 24.
- Counting 'between' as the full gap (4) instead of gap minus one.