Difficulty: Medium
Correct Answer: 9
Explanation:
Introduction / Context:This problem tests careful indexing and stable, pairwise swaps. We take the 10-digit sequence 5904627813 and swap positions in fixed pairs: (1↔6), (2↔7), (3↔8), (4↔9), (5↔10). Then we must read the fourth digit from the right of the resulting string.
Given Data / Assumptions:
Concept / Approach:Perform the swaps carefully without cascading errors (treat swaps as simultaneous or track in a copy). After the final arrangement, identify the 4th from right. Alternatively, compute that “4th from right” equals index 10−4+1 = 7 from the left.
Step-by-Step Solution:
Write indices: 1:5, 2:9, 3:0, 4:4, 5:6, 6:2, 7:7, 8:8, 9:1, 10:3.Swap (1,6): positions 1↔6 → 2 at pos1, 5 at pos6.Swap (2,7): positions 2↔7 → 7 at pos2, 9 at pos7.Swap (3,8): positions 3↔8 → 8 at pos3, 0 at pos8.Swap (4,9): positions 4↔9 → 1 at pos4, 4 at pos9.Swap (5,10): positions 5↔10 → 3 at pos5, 6 at pos10.Final sequence (1..10): 2 7 8 1 3 5 9 0 4 6.Fourth from right = index 7 from left = digit 9.Verification / Alternative check:Count from the right: (1)6, (2)4, (3)0, (4)9 → same result.
Why Other Options Are Wrong:
Common Pitfalls:Applying swaps in-place in a way that uses already-swapped values; miscounting “4th from right”; or indexing from zero. Work with a copied array or treat swaps as simultaneous.
Final Answer:9
Discussion & Comments