Hard
,Array
,String
,Hash Table
,Bit Manipulation
You are given an array of strings ideas
that represents a list of names to be used in the process of naming a company. The process of naming a company is as follows:
Choose 2 distinct names from ideas
, call them ideaA
and ideaB
.
Swap the first letters of ideaA
and ideaB
with each other.
If both of the new names are not found in the original ideas
, then the name ideaA
ideaB
(the concatenation of ideaA
and ideaB
, separated by a space) is a valid company name.
Otherwise, it is not a valid name.
Return the number of distinct valid names for the company.
Example 1:
Example 2:
Constraints:
ideas.length
<= 5 * 104ideas[i].length
<= 10ideas[i]
consists of lowercase English letters.ideas
are unique.Yen-Chi ChenThu, Feb 9, 2023
Time: m
為平均idea長度, 共有26*25/2=325
個pair group比較, 每個pair group比較花
Extra Space:
XD Feb 9, 2023
Yen-Chi ChenThu, Feb 9, 2023