Count Integers With Even Digit Sum solution leetcode – Given a positive integer num
, return the number of positive integers less than or equal to num
whose digit sums are even.
The digit sum of a positive integer is the sum of all its digits.
Input: num = 30 Output: 14 Explanation: The 14 integers less than or equal to 30 whose digit sums are even are 2, 4, 6, 8, 11, 13, 15, 17, 19, 20, 22, 24, 26, and 28.
Given head
which is a reference node to a singly-linked list. The value of each node in the linked list is either 0
or 1
. The linked list holds the binary representation of a number.
Return the decimal value of the number in the linked list.
Count Integers With Even Digit Sum solution leetcode
Input: head = [1,0,1] Output: 5 Explanation: (101) in base 2 = (5) in base 10
Count Integers With Even Digit Sum solution leetcode
Input: head = [0] Output: 0
Constraints:
- The Linked List is not empty.
- Number of nodes will not exceed
30
. - Each node’s value is either
0
or1
.