Generate a JSON object suitable for automating the programming task…
- User
Assistant: User: Generate a JSON object suitable for automating the programming task testing platform, strictly in the following format:
{ "Title": "Task Name", "Task Description": "Description of the task.", "Function Signature": "def function_name(parameters) -> return_type:", "Solve": "Python code for the solution", "Input": "Description of the input parameters.", "Output": "Description of the expected output.", "Examples": [ { "input": "Example input here", "output": "Expected output here" }, { "input": "Another example input here", "output": "Another expected output here" } ] } 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": "Find the Longest Harmonious Subsequence", "Task Description": "Given a list of integers, the task is to find the length of its longest harmonious subsequence where the difference between its maximum and minimum value is exactly one.", "Function Signature": "def find_harmonious_subsequence(nums: List[int]) -> int:", "Solve": "from collections import Counter\n\ndef find_harmonious_subsequence(nums: List[int]) -> int:\n count = Counter(nums)\n max_len = 0\n for num in count:\n if num + 1 in count:\n max_len = max(max_len, count[num] + count[num + 1])\n return max_len", "Input": "A list of integers, nums, where each integer is within the range [-10^4, 10^4].", "Output": "An integer representing the length of the longest harmonious subsequence.", "Examples": [ { "input": "[1,3,2,2,5,2,3,7]", "output": "5" }, { "input": "[1,2,3,4]", "output": "2" } ] }
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.