#K55347. Employee Department Update

    ID: 29955 Type: Default 1000ms 256MiB

Employee Department Update

Employee Department Update

You are given two JSON strings from standard input. The first JSON string represents an employees dictionary where each key is an employee ID and its corresponding value is an object containing the employee's name, age, and current department.

The second JSON string represents an updates dictionary with employee IDs as keys and new department names as values. Your task is to update the department field of each employee in the employees dictionary if an update for that employee exists. If an employee ID in the updates dictionary is not present in employees, ignore that update.

Finally, print the updated employees dictionary as a JSON string to standard output.

inputFormat

The input consists of two lines provided via standard input (stdin):

  • Line 1: A JSON string representing the employees dictionary. For example:
{ "E123": { "name": "John Doe", "age": 28, "department": "Sales" }, "E124": { "name": "Jane Smith", "age": 34, "department": "Engineering" } }
  • Line 2: A JSON string representing the updates dictionary. For example:
{ "E123": "Marketing", "E125": "HR" }

outputFormat

Output a single line to standard output (stdout) containing the updated employees dictionary as a JSON string.

## sample
{"E123": {"name": "John Doe", "age": 28, "department": "Sales"}, "E124": {"name": "Jane Smith", "age": 34, "department": "Engineering"}, "E125": {"name": "Sam Black", "age": 22, "department": "HR"}}
{"E123": "Marketing", "E126": "Finance", "E124": "Product"}
{"E123":{"name":"John Doe","age":28,"department":"Marketing"},"E124":{"name":"Jane Smith","age":34,"department":"Product"},"E125":{"name":"Sam Black","age":22,"department":"HR"}}