PROBLEM LINKS
DIFFICULTY
EASY
EXPLANATION
The solution proceeds in two steps. The first step is to read and store pairs of strings, and the second step is to perform a series of lookups. The most effective way to store the media types is using an associative array (such as the STL map in C++, or HashMap in Java), however the list is small enough that an array of strings would suffice. Determining the file extension requires first finding the position of the final ‘.’ character (using strrchr or rfind in C++, or lastIndexOf in Java), then discarding the remainder of the string (using substr in C++, or substring in Java).
SETTER’S SOLUTION
Can be found here.
TESTER’S SOLUTION
Can be found here.