|
Download cp/cp-10015.jsonl from winapiadmin/tinycodinglm: direct link, hf CLI and curl.
- Browser
- Download file 1.8 kB
-
https://huggingface.co/datasets/winapiadmin/tinycodinglm/resolve/main/cp/cp-10015.jsonl
- Command line
-
hf download hf://datasets/winapiadmin/tinycodinglm/cp/cp-10015.jsonl
-
curl -L -o cp-10015.jsonl https://huggingface.co/datasets/winapiadmin/tinycodinglm/resolve/main/cp/cp-10015.jsonl
1.8 kB
| {"type": "session", "harness": "opencode", "id": "cp-10015", "name": "LeetCode 0506: Relative Ranks"} | |
| {"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: Relative Ranks (Difficulty: Easy)\nTags: Array, Sorting, Heap (Priority Queue)\n\nYou are given an integer array score of size n, where score[i] is the score of the ith athlete in a competition. All the scores are guaranteed to be unique.\nThe athletes are placed based on their scores, where the 1st place athlete has the highest score, the 2nd place athlete has the 2nd highest score, and so on. The placement of each athlete determines their rank:\nReturn an array answer of size n where answer[i] is the rank of the ith athlete.\n\nExample 1:\nInput: score = [5,4,3,2,1]\nOutput: [\"Gold Medal\",\"Silver Medal\",\"Bronze Medal\",\"4\",\"5\"]\nExplanation: The placements are [1st, 2nd, 3rd, 4th, 5th].\n\nExample 2:\nInput: score = [10,3,8,9,4]\nOutput: [\"Gold Medal\",\"5\",\"Bronze Medal\",\"Silver Medal\",\"4\"]\nExplanation: The placements are [1st, 5th, 3rd, 2nd, 4th].\n\nConstraints:\n- n == score.length\n- 1 <= n <= 10^4\n- 0 <= score[i] <= 10^6\n- All the values in score are unique."}} | |
| {"type": "message", "message": {"role": "assistant", "content": "# Time: O(nlogn)\n# Space: O(n)\n\nclass Solution(object):\n def findRelativeRanks(self, nums):\n \"\"\"\n :type nums: List[int]\n :rtype: List[str]\n \"\"\"\n sorted_nums = sorted(nums)[::-1]\n ranks = [\"Gold Medal\", \"Silver Medal\", \"Bronze Medal\"] + map(str, range(4, len(nums) + 1))\n return map(dict(zip(sorted_nums, ranks)).get, nums)\n\n"}} | |