Hacker News new | ask | show | jobs
by tzs 2925 days ago
Exactly. On LeetCode, and similar sites, you write some function whose prototype they supply. They evaluate your solution by calling your function with assorted inputs for which they know the correct answer.

Here's what they want you to write for the first missing positive problem if you are using Python3:

  class Solution:
      def firstMissingPositive(self, nums):
        """
        :type nums: List[int]
        :rtype: int
        """
If you are allowed to mutate the input, you can use nums.sort(). If you are not allowed to mutate input, you would need to do something like sortedNums = sorted(nums) if you needed a sorted version of nums.