HardRating 2305
2306. Naming a Company
arrayhash-tablestringbit-manipulationenumeration
解題說明
C++ 解法
複雜度分析
虛擬碼
1. Group suffixes by first character into 26 sets 2. For each pair of first characters (a, b) where a < b: a. Count common suffixes between groups[a] and groups[b] b. sa = |groups[a]| - common c. sb = |groups[b]| - common d. ans += 2 * sa * sb 3. Return ans