Day - 20
Hello, dear readers! I am glad to see you here to read my post. I am going to post the 20th day of my coding challenge. Now you can see what I did actually.
/*
* @param {number[]} nums
* @return {number}
*/
var maximumCount = function (nums) {
let pos = [],
neg = [];
for (let i = 0; i < nums.length; i++) {
if (nums[i] == 0) {
continue;
} else if (nums[i] < 0) {
neg.push(nums[i]);
} else if (nums[i] > 0) {
pos.push(nums[i]);
}
}
return Math.max(pos.length, neg.length);
};
2. Problem 2535. Difference Between Element Sum and Digit Sum of an Array
/*
* @param {number[]} nums
* @return {number}
*/
var differenceOfSum = function (nums) {
let sum = nums.reduce((a, b) => a + b, 0);
let digitSum = nums
.join("")
.split("")
.reduce((a, b) => Number(a) + Number(b), 0);
let response = Math.abs(sum - digitSum);
return response;
};
That's all that I am going to share. I love your support for my posts. Thanks for your attention.