Interview Questions/Coding/Case Policy Normalizer

Case Policy Normalizer

Preview mode. Log in to edit, run, submit, and save progress.

Easy

Case Policy Normalizer

A moderation gateway receives incident codes with mixed uppercase and lowercase letters. Before forwarding a code, it must rewrite every letter using a single case. If uppercase letters are strictly more frequent than lowercase letters, the whole code is sent in uppercase. Otherwise, including a tie, the whole code is sent in lowercase. Process each received code independently. Input Format: The first line contains t, the number of test cases. Each test case contains one alphabetic string. Output Format: For each test case, print the normalized string.

Examples

Example 1
Input:
1
HoUse
Output:
house

Explanation: The code has two uppercase letters and three lowercase letters, so the normalized code is lowercase.

Approach hint

Start with the simplest clear approach, explain the trade-off, then move toward the cleaner answer.

Common mistake

Skipping assumptions, edge cases, or trade-offs can make an otherwise good answer feel incomplete.

solution.cpp