Summary
This post details a challenging string manipulation problem, known as the 'Alternate Deletion Problem,' encountered during an Axis Bank Online Assessment in 2025.
Full Experience
During my Online Assessment for Axis Bank in 2025, I was presented with a challenging string manipulation problem. The task involved repeatedly applying forward and backward alternate character deletions on a string formed by concatenating an initial string multiple times, with the ultimate goal of identifying the very last character removed.
Interview Questions (1)
You are given a string S, and an integer k ≥ 1.
First, form a new string T by concatenating the string S to itself k times.
You then repeatedly perform the following two operations alternatingly, until the string becomes empty:
- Operation 1 — Forward Elimination: Starting from the first character, delete every alternate character.
- Operation 2 — Backward Elimination: Starting from the last character, delete every alternate character
These two operations are applied repeatedly in the order: Op1, Op2, Op1, Op2, .......until all characters of T have been deleted.
Goal
Return the last character that gets deleted from the string during this entire elimination process.
Input Format
- A string S consisting of lowercase or uppercase letters.
- An integer k (1 ≤ k ≤ 10⁹ in optimized versions, or ≤ 10⁵ for direct-simulation versions).
Output Format
A single character: the last deleted character.