Accounts Merge

Difficulty: Medium | Category: Graph | Asked at: Google, Meta, Amazon | Platform: Unfoldd Arena

Accounts Merge ============== ### Problem Statement Given a list of employee email addresses and the merging information, find the correct department for each employee. The merging information is represented as a list of operations, where each operation is a tuple or array of three values: the current email, the merged employee's email, and the merged department. ### Rules and Constraints * The input will contain at most `100` employee email addresses. * Each employee email will be unique and in the format `email@example.com`. * The merging operations will not create any conflicts. * The input will not contain any invalid email addresses. * The algorithm should produce the correct department for each employee. ### Input and Output The input will be in the format of a list of operations, where each operation is a list or tuple of three values: the current email, the merged employee's email, and the merged department. The output should be a dictionary or hash map where each key is an employee email and the value is the corresponding department. ### Time and Space Complexity The algorithm should aim for a time complexity of O(n) and a space complexity of O(n), where `n` is the number of employee email addresses. ### Example **Input:** {"input_data":[1,2,3]} **Output:** [1,2,3]

Solve Accounts Merge online for free in Python, JavaScript, Java, C++, TypeScript, Go, Rust, PHP, Swift, Kotlin, Dart, Ruby, C, and C#. Practice Medium level coding interview problems with instant test case evaluation and AI-powered analysis.

Keywords: Accounts Merge solution, Accounts Merge leetcode, Accounts Merge python, Accounts Merge javascript,Accounts Merge java, Accounts Merge approach, how to solve Accounts Merge, medium coding problems, Graph problems, coding interview preparation, DSA practice free.

Accounts Merge

Medium

Accounts Merge

Problem Statement

Given a list of employee email addresses and the merging information, find the correct department for each employee. The merging information is represented as a list of operations, where each operation is a tuple or array of three values: the current email, the merged employee's email, and the merged department.

Rules and Constraints

  • The input will contain at most
    100
    employee email addresses.
  • Each employee email will be unique and in the format
    email@example.com
    .
  • The merging operations will not create any conflicts.
  • The input will not contain any invalid email addresses.
  • The algorithm should produce the correct department for each employee.

Input and Output

The input will be in the format of a list of operations, where each operation is a list or tuple of three values: the current email, the merged employee's email, and the merged department.

The output should be a dictionary or hash map where each key is an employee email and the value is the corresponding department.

Time and Space Complexity

The algorithm should aim for a time complexity of O(n) and a space complexity of O(n), where

n
is the number of employee email addresses.

Example

Input: {"input_data":[1,2,3]} Output: [1,2,3]

CompaniesGoogleMetaAmazon
JavaScript

Login to write code

Solve problems, verify your skills, and earn XP.