MIME2 - Editorial

PROBLEM LINKS

Practice
Contest

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.

just addition: n lines entered two strings, 1st is extension, 2nd is file type. and then q lines user inputs media names. coders task is to check if there exist any extension at any given file name, if no coder outputs “unknown”, if yes, coder now seeks for same extension’s file type through saved file extensions and types char array. if coder finds any equivalent file type for existing extension, then he outputs corresponding file type, if vice versa, he then outputs “unknown”

What is the problem with this code?