question archive 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

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

Subject:Computer SciencePrice:4.87 Bought16

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] •

devicenames[0] = "switch" is unique, uniqueDevicename[0) - "switch •

devicenames[1] = " is unique, unique Devicename/Oj-"tv •

devicenames/2) = devicenames(OJ. Add 1 at the end the previous unique username "switch", uniqueDevicename/2) -"switch 1" •

devicenames[3) = devicenames[1]. Add 1 at the end the previous unique username "v", uniqueDevicename/3) - tv1" •

devicenames[4devicenames[2]. Increment by 1 the number at the end of the previous unique username "switch 1", unique Devicendres[4]="switch2 •

devicenames(5) - devicenames/3). Increment by 1 the number at the end of the previous unique username "tv1", unique Devicenames(5) "2" •

return uniqueDevicenames switch, tv, switch 1, tv switch2', 'TV21

Function Description Complete the function deviceNamesSystem in the editor below. deviceNamesSystem has the following parameter(s): string devicenamesin: an array of device name strings in the order requested.

Returns stringin: an array of string usernames in the order assigned

Constraints

• 1sns 104

• 1 s length of devicenamesli s 20

• devicenamese contains only lowercase English letters in the range ascii a z Input Format for Custom Testing

Sample Case o Sample Input STDIN Function devicenames [] size n = 4 devicenames=["mixer","toaster", mixer – toaster mixer tv Sample Output o mixer toaster mixeri tv Explanation o • devicenames[0] = "mixer" is unique, unique Devicename[0]="mixer" • devicenames[1] = "toaster" is unique, unique Devicename[1]="toaster • devicenames[2] = devicenames(0). Add 1 at the end the previous unique device name "mixer", unique Devicename[2] ="mixer 1" • devicenames[3] = "ty" is unique, unique Devicename[3]="tv • unique Devicenames = ['mixer", "toaster", "mixer 1", "tv"

Option 1

Low Cost Option
Download this past answer in few clicks

4.87 USD

PURCHASE SOLUTION

Option 2

Custom new solution created by our subject matter experts

GET A QUOTE

rated 5 stars

Purchased 16 times

Completion Status 100%

Related Questions