LCS

AtCoder
IDdp_f
Time2000ms
Memory256MB
Difficulty
You are given strings $s$ and $t$. Find one longest string that is a subsequence of both $s$ and $t$. ## Constraints * $s$ and $t$ are strings consisting of lowercase English letters. * $1 \leq |s|, |t| \leq 3000$ ## Input Input is given from Standard Input in the following format: $s$ $t$ [samples] ## Notes A _subsequence_ of a string $x$ is the string obtained by removing zero or more characters from $x$ and concatenating the remaining characters without changing the order.
Samples
Input #1
axyb
abyxb
Output #1
axb

The answer is `axb` or `ayb`; either will be accepted.
Input #2
aa
xayaz
Output #2
aa
Input #3
a
z
Output #3
The answer is (an empty string).
Input #4
abracadabra
avadakedavra
Output #4
aaadara
API Response (JSON)
{
  "problem": {
    "name": "LCS",
    "description": {
      "content": "You are given strings $s$ and $t$. Find one longest string that is a subsequence of both $s$ and $t$.",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "dp_f"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "You are given strings $s$ and $t$. Find one longest string that is a subsequence of both $s$ and $t$.\n\n## Constraints\n\n*   $s$ and $t$ are strings consisting of lowercase English letters.\n*   $1 \\leq ...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments