← TCS questions
CodingeasyReported in a candidate post, Dec 2017

String processing

Filed under TCS

Free read 3 of 3

Determine if the operations should be performed independently on the original input string.

The question

Implement a function that takes a string and returns a dictionary containing the string with vowels removed, the string with vowels uppercased, and a string of characters at even indices.

Constraints

  • Input string length up to 1000
  • Vowels are defined as 'a', 'e', 'i', 'o', 'u'

Examples

Input
'apple'
Output
{'removed': 'ppl', 'uppercased': 'ApplE', 'even': 'ape'}
Why
Vowels are processed and even indices (0, 2, 4) are extracted.

Approach

  1. Determine if the operations should be performed independently on the original input string.

Solution

O(N) time, O(N) space

Python
class Solution:
    def process_string(self, s: str) -> dict:
        vowels = 'aeiouAEIOU'
        # Remove vowels
        no_v = ''.join([c for c in s if c not in vowels])
        # Uppercase vowels
        up_v = ''.join([c.upper() if c in vowels else c for c in s])
        # Even indices
        even = s[::2]
        return {'removed': no_v, 'uppercased': up_v, 'even': even}

Tips

  • What they are testing: Check strings with only vowels, only consonants, or empty strings to ensure robustness.
  • Common mistake: Modifying the string in-place during iteration, which is inefficient and impossible for immutable strings.

Related TCS questions

Collected from public candidate posts and coding forums. Updated Nov 2026.