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, hard and unique.
Assistant:
- Assistantjson
{ "Title": "Longest Consecutive Subsequence", "Task Description": "Given a list of integers, find the length of the longest consecutive elements sequence. The consecutive sequence does not require the elements to be adjacent in the array.", "Function Signature": "def longest_consecutive(nums: List[int]) -> int:", "Solve": "def longest_consecutive(nums: List[int]) -> int:\n num_set = set(nums)\n longest_streak = 0\n\n for num in num_set:\n if num - 1 not in num_set:\n current_num = num\n current_streak = 1\n\n while current_num + 1 in num_set:\n current_num += 1\n current_streak += 1\n\n longest_streak = max(longest_streak, current_streak)\n\n return longest_streak", "Input": "A list of integers, which can be unsorted and may contain duplicates.", "Output": "An integer representing the length of the longest consecutive elements sequence.", "Examples": [ { "input": "[100, 4, 200, 1, 3, 2]", "output": "4" }, { "input": "[0, 0, -1, 1]", "output": "3" } ] }
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.