1940. Longest Common Subsequence Between Sorted Arrays ¶
Approach 1: Naive¶
- Time: $O(\Sigma |\texttt{arrays[i]}|)$
- Space: $O(\max(|\texttt{arrays[i]}|))$
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|
Approach 2: Set Intersection¶
- Time: $O(\Sigma |\texttt{arrays[i]}|)$
- Space: $O(\max(|\texttt{arrays[i]}|))$
1 2 3 |
|