Longest Chain

Company: Edelwiess_14nov

Difficulty: medium

Problem Statement

Problem Description Given an array of words representing a dictionary, test each word to see if it can be made into another word in the dictionary when characters are removed one at a time. Each word represents its own first element of its string chain, so start with a string chain of length 1. Each time a character is removed, increment the string chain by 1. In order to remove a character, the resulting word must be in the original dictionary. Determine the longest string chain achievable for a given dictionary. Example 1 Input: words = ["a","b","ba","bca","bda","bdca"] n = 6 Output: 4 Explanation: One of the longest chains is "a" -> "ba" -> "bda" -> "bdca". Constraints 1 <= n <= 50000 1 <= |words[i]| <= 60, where 0 <= i < n Each words[i] is composed of lowercase letters in the range ascii[a-z]. Sample Case 0: Input 6 a ba bca bda bdca b Output 4 Explanation: Words = ["a", "ba", "bca", "bda", "bdca", "b"]. The longest chain is "a" -> "ba" -> "bda" -&g