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