Spaces:
Sleeping
Sleeping
Production-ready: add server/app.py with fallback-safe /reset, fix Dockerfile, add HF metadata, add task JSON files
dcc8fa3 | { | |
| "task_id": "hard-1", | |
| "difficulty": "hard", | |
| "description": "Optimize the function to find the maximum sum contiguous subarray (Kadane's algorithm). Current O(N^3) approach is too slow.", | |
| "buggy_code": "def max_subarray_sum(arr):\n if not arr: return 0\n max_sum = float('-inf')\n n = len(arr)\n for i in range(n):\n for j in range(i, n):\n current_sum = 0\n for k in range(i, j + 1):\n current_sum += arr[k]\n if current_sum > max_sum:\n max_sum = current_sum\n return max_sum", | |
| "test_code": "\nimport unittest\nimport random\nclass TestHard(unittest.TestCase):\n def test_basic(self):\n self.assertEqual(max_subarray_sum([-2,1,-3,4,-1,2,1,-5,4]), 6)\n def test_all_negative(self):\n self.assertEqual(max_subarray_sum([-5, -2, -9]), -2)\n def test_empty(self):\n self.assertEqual(max_subarray_sum([]), 0)\n def test_large(self):\n random.seed(42)\n arr = [random.randint(-100, 100) for _ in range(300)]\n ans = max_subarray_sum(arr)\n self.assertIsInstance(ans, int)\n", | |
| "optimal_time_seconds": 0.1 | |
| } | |