6. Device Name System
Suggested Problem Name: Device Name System
Suggested Function Name: deviceNamesSystem
Create unique device names to be used in a residential loT (Internet of Things) system. If a device name already exists in the system, an integer number is added at the end of the name to make it unique. The integer added starts with 1 and is incremented by 1 for each new request of an existing device name. Given a list of device name requests, process all requests and return an array of the corresponding unique device names.
Example
n=6
devicenames = ['switch', 'tv', 'switch', 'tv', 'switch', 'tv']
Function Description
Complete the function deviceNamesSystem in the editor below.
deviceNamesSystem has the following parameter(s):
string devicenames/n]: an array of device name strings in the order requested.
Returns
string [n] : an array of string usernames in the order assigned