File size: 1,741 Bytes
32486dc
 
 
 
 
 
 
1
2
3
4
5
6
7
{
    "default_initial_solution": "def longest_increasing_subsequence(nums):\n    n = len(nums)\n    dp = [1] * n\n    \n    for i in range(1, n):\n        for j in range(i):\n            if nums[i] > nums[j]:\n                dp[i] = max(dp[i], dp[j] + 1)\n    \n    max_length = max(dp)\n    lis = []\n    \n    for i in range(n - 1, -1, -1):\n        if dp[i] == max_length:\n            lis.append(nums[i])\n            max_length -= 1\n    \n    return len(lis[::-1])",
    "default_target_solution": "import bisect\n\ndef longest_increasing_subsequence(nums):\n    if not nums:\n        return 0\n    \n    tails = []\n    \n    for num in nums:\n        pos = bisect.bisect_left(tails, num)\n        if pos == len(tails):\n            tails.append(num)\n        else:\n            tails[pos] = num\n    \n    return len(tails)",
    "default_loss_system_prompt": "You are a smart language model that evaluates code snippets. You do not solve problems or propose new code snippets, only evaluate existing solutions critically and give very concise feedback.",
    "default_problem_description": "Longest Increasing Subsequence (LIS)\n\nProblem Statement:\nGiven a sequence of integers, find the length of the longest subsequence that is strictly increasing. A subsequence is a sequence that can be derived from another sequence by deleting some or no elements without changing the order of the remaining elements.\n\nInput:\nThe input consists of a list of integers representing the sequence.\n\nOutput:\nThe output should be an integer representing the length of the longest increasing subsequence.",
    "instruction": "Think about the problem and the code snippet. Does the code solve the problem? What is the runtime complexity?"
}