REL201 - Editorial

PROBLEM LINK:

Practice 
Contest

Author: Divyesh Savaliya 
Editorialist: Divyesh Savaliya

DIFFICULTY:

Easy

PREREQUISITES:

Hashing

PROBLEM:

You have a lot of functions lying around and you decided to compose them into a single meaningful function. It is given that for any two functions, f and g, the input of f and input of g are different and similarly their outputs are also different. It is also given that all given functions can be composed into one function only. You task is to find the composed function.

EXPLANATION:

This is an easy problem, in which you have to search for the next function based on its input type. So, you should be able to create some structure so that searching for a function takes mlogn time. A map can be used, with key as function input string. Start with function having input given as “inp”, and then read successive functions from the map, adding them to a vector, then output the vector in reverse.

AUTHOR’S SOLUTIONS:

Author’s solution can be found here.

//