1748 唯一元素的和
给你一个整数数组 nums 。数组中唯一元素是那些只出现 恰好一次 的元素。请你返回 nums 中唯一元素的 和 。
示例 1:
输入:nums = [1,2,3,2] 输出:4 解释:唯一元素为 [1,3] ,和为 4 。
示例 2:输入:nums = [1,1,1,1,1] 输出:0 解释:没有唯一元素,和为 0 。
来源:力扣(LeetCode)
链接:https://leetcode-cn.com/problems/sum-of-unique-elements
class Solution:
def sumOfUnique(self, nums: List[int]) -> int:
return sum(num for num, cnt in Counter(nums).items() if cnt == 1)
# 作者:LeetCode-Solution
# 链接:https://leetcode-cn.com/problems/sum-of-unique-elements/solution/wei-yi-yuan-su-de-he-by-leetcode-solutio-tueh/
618 学生地理信息报告
SELECT
MAX(CASE continent WHEN 'Asia'THEN NAME ELSE NULL END) AS Asia,
MAX(CASE continent WHEN 'America'THEN NAME ELSE NULL END) AS America,
MAX(CASE continent WHEN 'Europe'THEN NAME ELSE NULL END) AS Europe
FROM
(SELECT *, ROW_NUMBER() OVER (PARTITION BY continent ORDER BY NAME) rk FROM student) t
GROUP BY rk;
# 作者:pipideveloper
# 链接:https://leetcode-cn.com/problems/students-report-by-geography/solution/zong-jie-ge-lei-biao-ge-ge-shi-hua-wen-t-tl4e/