Tap here to switch tabs
Problem
Submissions

Problem: Groups of Strings

Try to solve the Groups of Strings problem.

Statement

You are given a 00 indexed string array words. Each string in words consists of distinct lowercase English letters.

Two strings s1 and s2 are considered connected if s1 can be obtained from s2 by applying any of the following operations at most once:

  1. Adding any single lowercase English letter.

  2. Deleting any single lowercase English letter.

  3. Replacing any single lowercase English letter with any other lowercase English letter.

A group is a subset of strings from words such that every string in the group is connected directly or indirectly to every other string in the same group.

Return an array ans of size 22 where:

  • ans[0] is the total number of disjoint groups formed by the strings in words.

  • ans[1] is the maximum size of a group.

Constraints:

  • 1≤1 \leq words.length ≤2imes104\leq 2 imes 10^4

  • 1≤1 \leq words[i].length ≤26\leq 26

  • words[i] consists of lowercase English letters only.

  • No letter occurs more than once in words[i].

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Groups of Strings

Try to solve the Groups of Strings problem.

Statement

You are given a 00 indexed string array words. Each string in words consists of distinct lowercase English letters.

Two strings s1 and s2 are considered connected if s1 can be obtained from s2 by applying any of the following operations at most once:

  1. Adding any single lowercase English letter.

  2. Deleting any single lowercase English letter.

  3. Replacing any single lowercase English letter with any other lowercase English letter.

A group is a subset of strings from words such that every string in the group is connected directly or indirectly to every other string in the same group.

Return an array ans of size 22 where:

  • ans[0] is the total number of disjoint groups formed by the strings in words.

  • ans[1] is the maximum size of a group.

Constraints:

  • 1≤1 \leq words.length ≤2imes104\leq 2 imes 10^4

  • 1≤1 \leq words[i].length ≤26\leq 26

  • words[i] consists of lowercase English letters only.

  • No letter occurs more than once in words[i].