BackmediumStrings Oracle Atlassian

Galactic Transmission 3 Solution

Problem Statement

Given a list of possible messages and a target transmission, determine the length of the longest chain of transmissions.

Example 1
Input
['worldhello', 'world', 'hello'], 'worldhello'
Output
2

Explanation: Step-by-step: with input ['worldhello', 'world', 'hello'], we find the longest chain starting from 'worldhello' which is 'worldhello' and 'world'. Therefore, the output is 2.

Example 2
Input
['hello', 'hell', 'hel', 'hello'], 'hello'
Output
4

Explanation: Step-by-step: with input ['hello', 'hell', 'hel', 'hello'], we find the longest chain starting from 'hello' which is 'hello', 'hell', 'hel', and 'hello' itself. Therefore, the output is 4.

Constraints

  • 2 <= number of messages <= 100
  • 1 <= length of each message <= 10
  • All messages are lowercase English letters.
Live Compiler
Loading...
Test Cases & Output
🔒 Sign up to run your code

🚀 Practice this problem

Run code, get AI hints & track streak

Sign Up Free