Hi, I have a problem. My JSON is failing the tests. Please analyze the…
- User
Assistant: User: Hi, I have a problem. My JSON is failing the tests. Please analyze the following JSON and fix it so that it passes the tests. Here’s the JSON: "Prepared Solve Code:\ndef max_non_adjacent_sum(nums: List[int]) -> int:\ndef max_non_adjacent_sum(nums):\n if not nums:\n return 0\n if len(nums) == 1:\n return nums[0]\n prev = 0\n curr = 0\n for num in nums:\n temp = curr\n curr = max(prev + num, curr)\n prev = temp\n return curr\n\nPrepared Solve Code:\ndef max_non_adjacent_sum(nums: List[int]) -> int:\ndef max_non_adjacent_sum(nums):\n if not nums:\n return 0\n if len(nums) == 1:\n return nums[0]\n prev = 0\n curr = 0\n for num in nums:\n temp = curr\n curr = max(prev + num, curr)\n prev = temp\n return curr\n\n" Ensure that:
- The solution must not use any imports in the code (i.e., no import statements).
- Answer format must be json with that structure { "Title": "Task Name", "Task Description": "Description of the task.", "Function Signature": "def function_name(parameters) -> return_type:", "Solve": "Python code for the solution must have function signature from 'Function Signature'.", "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" } ] } Assistant:
- Assistant
{"Title": "Maximum Non-Adjacent Sum", "Task Description": "Calculate the maximum sum of non-adjacent numbers in a list.", "Function Signature": "def max_non_adjacent_sum(nums: List[int]) -> int:", "Solve": "def max_non_adjacent_sum(nums):\n if not nums:\n return 0\n if len(nums) == 1:\n return nums[0]\n prev = 0\n curr = 0\n for num in nums:\n temp = curr\n curr = max(prev + num, curr)\n prev = temp\n return curr\n", "Input": "A list of integers, which can include negative and positive numbers.", "Output": "The maximum sum possible by adding non-adjacent numbers from the list.", "Examples": [ {"input": "[3, 2, 5, 10, 7]", "output": "15"}, {"input": "[3, 2, 7, 10]", "output": "13"} ]}