Skip to content

Commit 594b419

Browse files
committed
Time: 8 ms (10.87%) | Memory: 18 MB (21.20%) - LeetSync
1 parent b6987bc commit 594b419

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
class Solution:
22
def differenceOfSums(self, n: int, m: int) -> int:
3-
num1 = sum(num for num in range(1, n + 1) if num % m != 0)
4-
num2 = sum(num for num in range(1, n + 1) if num % m == 0)
5-
return num1 - num2
3+
return sum(num if num % m != 0 else -num for num in range(1, n + 1))
4+
65

0 commit comments

Comments
 (0)