#3598
Longest Common Prefix Between Adjacent Strings After Removals
expert · 1100 · lc medium +32 · 32.3% accepted · 83 likes · top 10%
Description
For each index i from 0 to words.length - 1, remove words[i] and compute the maximum length of any common prefix shared by adjacent string pairs in the remaining array.
Return an array answer where answer[i] holds that maximum prefix length. Use 0 when no adjacent pair remains or no pair shares a prefix.
Code
1
2
3