Learn practical skills, build real-world projects, and advance your career

Updated 3 years ago

## Longest Common Subsequence

QUESTION 1: Write a function to find the length of thelongest common subsequencebetween two sequences. E.g. Given the strings "serendipitous" and "precipitation", the longest common subsequence is "reipito" and its length is 7.A "sequence" is a group of items with a deterministic ordering. Lists, tuples and ranges are some common sequence types in Python.

A "subsequence" is a sequence obtained by deleting zero or more elements from another sequence. For example, "edpt" is a subsequence of "serendipitous".

#### General case

#### Test cases

- General case (string)
- General case (list)
- No common subsequence
- One is a subsequence of the other
- One sequence is empty
- Both sequences are empty
- Multiple subsequences with same length
- “abcdef” and “badcfe”

```
def len_lcs(seq1, seq2):
pass
```

`!pip install jovian --upgrade --quiet`

`import jovian `

`jovian.commit(project="dynamic-programming-problems")`

```
[jovian] Attempting to save notebook..
[jovian] Updating notebook "haoyu777777/dynamic-programming-problems" on https://jovian.ai
[jovian] Uploading notebook..
[jovian] Uploading additional files...
[jovian] Committed successfully! https://jovian.ai/haoyu777777/dynamic-programming-problems
```