2014. Longest Subsequence Repeated k Times
https://leetcode.com/problems/longest-subsequence-repeated-k-times
Description
You are given a string s of length n, and an integer k. You are tasked to find the longest subsequence repeated k times in string s.
A subsequence is a string that can be derived from another string by deleting some or no characters without changing the order of the remaining characters.
A subsequence seq is repeated k times in the string s if seq * k is a subsequence of s, where seq * k represents a string constructed by concatenating seq k times.
For example,
"bba"is repeated2times in the string"bababcba", because the string"bbabba", constructed by concatenating"bba"2times, is a subsequence of the string"**b**a**bab**c**ba**".
Return the longest subsequence repeated k times in string s. If multiple such subsequences are found, return the lexicographically largest one. If there is no such subsequence, return an empty string.
Example 1:

Example 2:
Example 3:
Example 4:
Constraints:
n == s.length2 <= n, k <= 20002 <= n < k * 8sconsists of lowercase English letters.
ac
Last updated
Was this helpful?