← TCS questions

Camel Case Conversion

Filed under TCS · Also reported at Optum (UnitedHealth Group)

Free read 1 of 3

Confirm the exact definition of 'opposite to camel case' (usually snake_case or space-separated lowercase words from camelCase).

The question

Given a sentence or string, process it in a way opposite to standard camel case conversion rules (e.g., converting a camelCase string into space-separated words with lowercase letters, or vice versa depending on exact prompt conventions).

Constraints

  • 1 <= string length <= 1000
  • String contains alphanumeric characters and spaces.

Examples

Input
"camelCaseString"
Output
"camel case string"
Why
Uppercase letters are preceded by a space and converted to lowercase.

Approach

  1. Confirm the exact definition of 'opposite to camel case' (usually snake_case or space-separated lowercase words from camelCase).

Solution

O(N) time, O(N) space

Python
import re
def reverse_camel_case(s):
    res = re.sub(r'([A-Z])', r' \1', s)
    return res.lower().strip()

Tips

  • What they are testing: Test with all lowercase, all uppercase, mixed camelCase, and strings with numbers.
  • Common mistake: Incorrectly handling consecutive uppercase letters or missing the first character capitalization rule.

Related TCS questions

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