Find Last Character

Problem Overview

  • Find the last remaining character after repeatedly deleting every other character, alternating starts from the first and last positions.
  • Input: alphanumeric string S (may include '$', '#', '&', '*') and integer K; form a new string by repeating S K times.
  • Output: the single-character string that survives; constraints are unspecified.
  • String-processing elimination problem for coding interview practice.
  • Asked in Google interviews; a classic interview question.

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Input Variables
Execution Result: