Problem Link - Id and Ship Practice Problem in 500 to 1000 difficulty problems
Problem Statement:
In this problem, we are asked to map a given ship class ID (a single letter) to its corresponding ship class name. The input consists of multiple test cases, each containing a character representing the ship class ID. We need to output the corresponding ship class for each test case.
Approach:
- For each test case, we need to check which ship class the provided class ID corresponds to.
- The ship class is determined using simple
if-else
checks for each of the valid IDs (‘B’, ‘C’, ‘D’, ‘F’ and their lowercase counterparts).
Complexity:
- Time Complexity:
O(1)
Simple conditional statements for each test case. - Space Complexity:
O(1)
No extra space used