2894: Divisible-and-Non-divisible-Sums-Difference
Easy
Lowkey, just follow what the question tells you to do.
Code:
class Solution {
public:
int differenceOfSums(int n, int m) {
int divisible = 0, notDivisible = 0;
for (int i = 1; i <= n; ++i) {
if ((i % m) != 0) {
+= i;
notDivisible } else {
+= i;
divisible }
}
return notDivisible - divisible;
}
};