https://leetcode.com/problems/divisible-and-non-divisible-sums-difference/description/
1 2 3 4 5 6 7 | class Solution: def differenceOfSums(self, n: int, m: int) -> int: num2 = [x for x in range(1, n + 1) if x % m ==0] num1 = [x for x in range(1, n + 1) if x % m !=0] return sum(num1) - sum(num2) | cs |
반응형
'python-algorithm' 카테고리의 다른 글
leetcode 2706. Buy Two Chocolates (0) | 2024.01.05 |
---|---|
leetcode 2843. Count Symmetric Integers (0) | 2024.01.05 |
leetcode 2974. Minimum Number Game (0) | 2024.01.05 |
leetcode 2643. Row With Maximum Ones (1) | 2024.01.02 |
leetcode 2788. Split Strings by Separator (1) | 2024.01.02 |
댓글