#3485
Longest Common Prefix of K Strings After Removal
international master · 2135 · lc hard +32 · 23.6% accepted · 63 likes · top 3%
Description
Given string array words and integer k, compute for each index i the length of the longest common prefix shared by any k strings chosen (at distinct indices) from words with element i removed.
If removing element i leaves fewer than k strings, set answer[i] = 0.
Return the array answer.
Code
1
2
3