Fix JSON object suitable for automating the programming task testing…
- User
Assistant: User: Fix JSON object suitable for automating the programming task testing platform, strictly in the following format:
{ "Title": "Longest Palindromic Subsequence", "Task Description": "Given a string, find the length of the longest subsequence that is a palindrome. A subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements.", "Function Signature": "def longest_palindromic_subsequence(s: str) -> int:", "Solve": "def longest_palindromic_subsequence(s: str) -> int:\n n = len(s)\n dp = [[0] * n for _ in range(n)]\n\n for i in range(n):\n dp[i][i] = 1\n\n for length in range(2, n + 1):\n for i in range(n - length + 1):\n j = i + length - 1\n if s[i] == s[j]:\n dp[i][j] = dp[i + 1][j - 1] + 2\n else:\n dp[i][j] = max(dp[i + 1][j], dp[i][j - 1])\n\n return dp[0][n - 1]", "Input": "A string 's' of length n (1 <= n <= 1000) consisting of lowercase English letters.", "Output": "An integer representing the length of the longest palindromic subsequence in the string.", "Examples": [ { "input": "bbabcbcab", "output": "7" }, { "input": "agbdba", "output": "5" } ] }
Ensure that the JSON follows this exact structure and does not include any additional text or variations. The task should be complex and unique, avoiding direct copying from common platforms like LeetCode or similar sources.
Assistant:
- Assistant
{ "Title": "Longest Palindromic Subsequence", "Task Description": "Given a string, find the length of the longest subsequence that is a palindrome. A subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements.", "Function Signature": "def longest_palindromic_subsequence(s: str) -> int:", "Solve": "def longest_palindromic_subsequence(s: str) -> int:\n n = len(s)\n dp = [[0] * n for _ in range(n)]\n\n for i in range(n):\n dp[i][i] = 1\n\n for length in range(2, n + 1):\n for i in range(n - length + 1):\n j = i + length - 1\n if s[i] == s[j]:\n dp[i][j] = dp[i + 1][j - 1] + 2\n else:\n dp[i][j] = max(dp[i + 1][j], dp[i][j - 1])\n\n return dp[0][n - 1]", "Input": "A string 's' of length n (1 <= n <= 1000) consisting of lowercase English letters.", "Output": "An integer representing the length of the longest palindromic subsequence in the string.", "Examples": [ { "input": "bbabcbcab", "output": "7" }, { "input": "agbdba", "output": "5" } ] }
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.