FastPrepFastPrep
Problem Brief

Find Longest Chain

FULLTIMEOA

Given a dictionary of many words:

- bac, ac, a, c, bads

For each word, each time you can delete one letter, and the resulting word must still be in the dictionary. The task is to find the longest chain that can be formed.

1Example 1

Input
words = ["bac", "ac", "a", "c", "bads"]
Output
3
Explanation

The longest chain that can be formed starting with "bac" is "bac" -> "ac" -> "a", which has a length of 3.

Constraints

Limits and guarantees your solution can rely on.

๐Ÿ“๐Ÿ“
public int longestChain(String[] words) {
  // write your code here
}
Input

words

["bac", "ac", "a", "c", "bads"]

Output

3

Sign in to submit your solution.