0% completed
Problem Statement
Given a sequence, find the length of its longest repeating subsequence (LRS). A repeating subsequence will be the one that appears at least twice in the original sequence and is not overlapping (i.e. none of the corresponding characters in the repeating subsequences have the same index).
Example 1:
Input: <span style="color:blue">"t o m o r r o w"</span>
Output: <span style="color:green">2</span>
Explanation: The longest repeating subsequence is "or" {t<span style="color:red">o</span>m<span style="color:green">o</span><span style="color:red">r</span><span style="color:green">r</span>ow}.
Example 2:
Input: <span style="color:blue">"a a b d b c e c"</span>
Output: <span style="color:green">3</span>
Explanation: The longest repeating subsequence is "a b c" {<span style="color:red">a</span> <span style="color:green">a</span> <span style="color:red">b</span> d <span style="color:green">b</span> <span style="color:red">c</span> e <span style="color:green">c</span>}.
Example 3:
Input: <span style="color:blue">"f m f f"</span>
Output: <span style="color:green">2</span>
Explanation: The longest repeating subsequence is "f f" {<span style="color:red">f</span> m <span style="color:red">f</span> f, f m <span style="color:green">f f</span>}. Please note the second last character is shared in LRS.
Try it yourself
Try solving this question here:
.....
.....
.....
Table of Contents
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible