Tap here to switch tabs
Problem
Submissions

Problem: Naming a Company

Naming a Company asks you to count ordered pairs of distinct idea strings whose first letters can be swapped to create two new names, neither already in the original array.

Statement

You are given an array of unique strings ideas representing a collection of candidate names for a company. A valid company name is formed using the following process:

  1. Select 22 distinct words from ideas, denoted as ideaA and ideaB.

  2. Swap the first character of ideaA with the first character of ideaB.

  3. If both newly created words do not exist in the original ideas array, then the pair forms a valid company name formatted as the first new word followed by a space and the second new word.

  4. Otherwise, the pair is considered invalid.

Return the total number of distinct valid company names that can be formed.

Constraints:

  • 2≤2 \leq ideas.length ≤5imes104\leq 5 imes 10^4

  • 1≤1 \leq ideas[i].length ≤10\leq 10

  • ideas[i] consists of lowercase English letters.

  • All the strings in ideas are unique.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Naming a Company

Naming a Company asks you to count ordered pairs of distinct idea strings whose first letters can be swapped to create two new names, neither already in the original array.

Statement

You are given an array of unique strings ideas representing a collection of candidate names for a company. A valid company name is formed using the following process:

  1. Select 22 distinct words from ideas, denoted as ideaA and ideaB.

  2. Swap the first character of ideaA with the first character of ideaB.

  3. If both newly created words do not exist in the original ideas array, then the pair forms a valid company name formatted as the first new word followed by a space and the second new word.

  4. Otherwise, the pair is considered invalid.

Return the total number of distinct valid company names that can be formed.

Constraints:

  • 2≤2 \leq ideas.length ≤5imes104\leq 5 imes 10^4

  • 1≤1 \leq ideas[i].length ≤10\leq 10

  • ideas[i] consists of lowercase English letters.

  • All the strings in ideas are unique.