Practice

Extract Country Code

2025/May/Jun·Variant 1
MEDIUMString Processing

A telephone number is input as a 13-character string. The first character is always '+', followed by a 2-digit country code (e.g. "+441234567890").

Extract the 2-digit country code and check its value:

  • Code "44" → output UK
  • Code "20" → output Egypt
  • Any other code → output Unknown

Input: A single 13-character string. Output: UK, Egypt, or Unknown.

Example:

Input:  +201234567890
Output: Egypt
Premium is coming soon. All grading features are currently unlocked.

Sample Test Cases

Test 1: UK country code
Inputs: +441234567890
Expected: UK
Test 2: Egypt country code
Inputs: +209876543210
Expected: Egypt
Test 3: Unknown country code
Inputs: +115555555555
Expected: Unknown
Press Ctrl+Enter to run your code
or Ctrl+Shift+Enter to grade