FastPrepLongest String Chain
Problems/Longest String Chain

Longest String Chain

LinkedIn logoLinkedIn● MediumFULLTIMEOA

Updated Sep 2026

QuestionFunctionExamplesConstraints

Problem statement

You are given an array of words consisting of lowercase English letters.

A word first is a predecessor of second when inserting exactly one letter anywhere in first, without changing the order of its existing letters, produces second. For example, abc is a predecessor of abac, but cba is not a predecessor of bcaa.

A word chain is a sequence in which every word is a predecessor of the next word. A single word is a valid chain of length one.

Return the greatest possible length of a chain formed from the given words.

Function

longestStrChain(words: String[]) → int

Examples

Example 1

words = ["a","b","ba","bca","bda","bdca"]return = 4

One longest chain is ["a", "ba", "bda", "bdca"], which has length 4.

Example 2

words = ["xbc","pcxbcf","xb","cxbc","pcxbc"]return = 5

All five words form the chain ["xb", "xbc", "cxbc", "pcxbc", "pcxbcf"].

Example 3

words = ["abcd","dbqca"]return = 1

No word is a predecessor of the other, so a single-word chain such as ["abcd"] is longest.

Constraints

  • 1 <= words.length <= 1000
  • 1 <= words[i].length <= 16
  • Every word contains only lowercase English letters.

More LinkedIn interview questions

  • Allocate Mailboxes with Squared DistanceONSITE INTERVIEW · Seen Nov 2026
  • Find Leaves of a Binary TreeONSITE INTERVIEW · Seen Nov 2026
  • Max Points on a LineONSITE INTERVIEW · Seen Nov 2026
  • Maximum Product of a Contiguous SubarrayPHONE SCREEN · Seen Nov 2026
  • Maximum Sum of a Contiguous SubarrayPHONE SCREEN · Seen Nov 2026
  • Merge Two Sorted ListsPHONE SCREEN · Seen Nov 2026
  • Sqrt(x)PHONE SCREEN · Seen Nov 2026
  • Total Years of Work ExperiencePHONE SCREEN · Seen Nov 2026
  • Explore an Unknown Grid and Find a PathONSITE INTERVIEW · Seen Nov 2026
  • Fire Station Response BillONSITE INTERVIEW · Seen Nov 2026

Similar questions at other companies

  • Longest String ChainVisa · OAVisa interview questions
  • Count Equal-Frequency SubsequencesExpedia · OAExpedia interview questions
  • String Formation (Also for AI/ML Software Engineer Intern :)Snowflake · OASnowflake interview questions
  • Word BreakAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Word BreakMoveworks · ONSITE INTERVIEWMoveworks interview questions
  • Word Break with a Reusable DictionaryMeta · ONSITE INTERVIEWMeta interview questions
  • Minimum Dictionary SegmentsGoogle · PHONE SCREENGoogle interview questions
  • Word BreakBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Can the Text Split Into Dictionary WordsAdobe · PHONE SCREENAdobe interview questions
  • Longest Common URL History RunDatadog · PHONE SCREENDatadog interview questions

LinkedIn interview experiences

  • LinkedIn Senior MLE Interview Questions: 1 Experience
  • LinkedIn Staff AI Engineer Phone Screens: 1 Experience
  • LinkedIn Experienced MLE Onsite: 1 Experience
  • LinkedIn Coding with AI Interview: 4 Experiences
  • LinkedIn Experienced Infrastructure SWE Onsite: 1 Experience
All LinkedIn interview questionsSee LinkedIn hiring insights
Saved
class Solution {
    public int longestStrChain(String[] words) {
      // write your code here
    }

}
Checking account…