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 Median of Two Sorted Arrays", "Task Description": "Given two sorted arrays nums1 and nums2 of size m and n, find the median of the two sorted arrays in O(log(min(m,n))) time complexity.", "Function Signature": "def find_median_sorted_arrays(nums1: List[int], nums2: List[int]) -> float:", "Solve": "def find_median_sorted_arrays(nums1: List[int], nums2: List[int]) -> float:\n if len(nums1) > len(nums2):\n nums1, nums2 = nums2, nums1\n x, y = len(nums1), len(nums2)\n low, high = 0, x\n while low <= high:\n partition_x = (low + high) // 2\n partition_y = (x + y + 1) // 2 - partition_x\n max_left_x = float('-inf') if partition_x == 0 else nums1[partition_x - 1]\n min_right_x = float('inf') if partition_x == x else nums1[partition_x]\n max_left_y = float('-inf') if partition_y == 0 else nums2[partition_y - 1]\n min_right_y = float('inf') if partition_y == y else nums2[partition_y]\n if max_left_x <= min_right_y and max_left_y <= min_right_x:\n if (x + y) % 2 == 0:\n return (max(max_left_x, max_left_y) + min(min_right_x, min_right_y)) / 2\n else:\n return max(max_left_x, max_left_y)\n elif max_left_x > min_right_y:\n high = partition_x - 1\n else:\n low = partition_x + 1\n raise ValueError(\"Input arrays are not sorted\")", "Input": "Two sorted lists of integers, nums1 and nums2.", "Output": "A float representing the median of the two sorted arrays.", "Examples": [ { "input": "nums1 = [1, 3], nums2 = [2]", "output": "2.0" }, { "input": "nums1 = [1, 2], nums2 = [3, 4]", "output": "2.5" } ] }
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.