Facebook | Phone Screen
Anonymous User
2390

Find longest subsequence in s that repeats n times. If multiple output any.

Examples:
s = "0011100111" and n = 3 should output "11"
s = "0011100111" and n = 2 should output "00111"
s = "0011100111" and n = 4 should output "1" or "0"

Clarification: For a subsequence to "repeat" it means that if the first sequence is the starts at index i and ends at index j, then the next sequence must start after index j.

Had no idea how to solve it or start it. I'm pretty sure I failed.

I should also add that this was the hint version of the question. The original question was given a string s, find a subsequence k that gives maximum score where score is given as len(k)*(# of repetitions of k).

Comments (12)