LeetCode 3782 - Last Remaining Integer After Alternating Deletion Operations

Before I write the full guide, I want to confirm one critical detail because the examples appear inconsistent with the stated operations.

LeetCode Problem 3782

Difficulty: πŸ”΄ Hard
Topics: Math, Recursion

Solution

Before I write the full guide, I want to confirm one critical detail because the examples appear inconsistent with the stated operations.

The statement says:

  • Operation 1: Starting from the left, delete every second number

Example transforms [1,2,3,4,5,6,7,8] β†’ [1,3,5,7]

This means it is deleting positions 2,4,6,8 and keeping odd positions.

However, for Operation 2 on [1,3,5,7], the example gives:

[1,3,5,7] β†’ [3,7]

If we truly β€œstart from the right and delete every second number,” there are two possible interpretations:

  • delete 7,3 β†’ remaining [1,5]
  • keep alternating from the right β†’ remaining [3,7]

The example chooses [3,7], which changes the rule interpretation.

Can you confirm which version LeetCode 3782 actually uses?

  1. Exactly as written in your prompt/examples (8 β†’ 3, 5 β†’ 1)
  2. The standard elimination-game interpretation (similar to LeetCode 390), where alternating deletions yield different outputs

I want to make sure the algorithm, proof, worked examples, and test cases all match the intended problem behavior exactly.