|
Download cp/cp-10039.jsonl from winapiadmin/tinycodinglm: direct link, hf CLI and curl.
- Browser
- Download file 1.83 kB
-
https://huggingface.co/datasets/winapiadmin/tinycodinglm/resolve/main/cp/cp-10039.jsonl
- Command line
-
hf download hf://datasets/winapiadmin/tinycodinglm/cp/cp-10039.jsonl
-
curl -L -o cp-10039.jsonl https://huggingface.co/datasets/winapiadmin/tinycodinglm/resolve/main/cp/cp-10039.jsonl
1.83 kB
| {"type": "session", "harness": "opencode", "id": "cp-10039", "name": "LeetCode 0532: K Diff Pairs In An Array"} | |
| {"type": "message", "message": {"role": "system", "content": "You are an expert LeetCode problem solver. You solve problems efficiently with clean code."}} | |
| {"type": "message", "message": {"role": "user", "content": "Problem: K-diff Pairs in an Array (Difficulty: Medium)\nTags: Array, Hash Table, Two Pointers, Binary Search, Sorting\n\nGiven an array of integers nums and an integer k, return the number of unique k-diff pairs in the array.\nA k-diff pair is an integer pair (nums[i], nums[j]), where the following are true:\nNotice that |val| denotes the absolute value of val.\n\nExample 1:\nInput: nums = [3,1,4,1,5], k = 2\nOutput: 2\nExplanation: There are two 2-diff pairs in the array, (1, 3) and (3, 5).\nAlthough we have two 1s in the input, we should only return the number of unique pairs.\n\nExample 2:\nInput: nums = [1,2,3,4,5], k = 1\nOutput: 4\nExplanation: There are four 1-diff pairs in the array, (1, 2), (2, 3), (3, 4) and (4, 5).\n\nExample 3:\nInput: nums = [1,3,1,5,4], k = 0\nOutput: 1\nExplanation: There is one 0-diff pair in the array, (1, 1).\n\nConstraints:\n- 1 <= nums.length <= 10^4\n- -107 <= nums[i] <= 10^7\n- 0 <= k <= 10^7"}} | |
| {"type": "message", "message": {"role": "assistant", "content": "# Time: O(n)\n# Space: O(n)\n\nclass Solution(object):\n def findPairs(self, nums, k):\n \"\"\"\n :type nums: List[int]\n :type k: int\n :rtype: int\n \"\"\"\n if k < 0: return 0\n result, lookup = set(), set()\n for num in nums:\n if num-k in lookup:\n result.add(num-k)\n if num+k in lookup:\n result.add(num)\n lookup.add(num)\n return len(result)\n\n"}} | |