MJay
[Array] - 1085 본문
Given an array A of positive integers, let S be the sum of the digits of the minimal element of A.
Return 0 if S is odd, otherwise return 1.
Example 1:
Input: [34,23,1,24,75,33,54,8] Output: 0 Explanation: The minimal element is 1, and the sum of those digits is S = 1 which is odd, so the answer is 0.
Example 2:
Input: [99,77,33,66,55] Output: 1 Explanation: The minimal element is 33, and the sum of those digits is S = 3 + 3 = 6 which is even, so the answer is 1.
Note:
- 1 <= A.length <= 100
- 1 <= A[i].length <= 100
divmod - 몫, 나머지 를 생각해야 한다. 이걸로 나온 결과를 계속 더하면 된다.
even 일때 1 이여 하니까 1 - s % 2
'Programming > LeetCode' 카테고리의 다른 글
[DP] - 121. Best Time to Buy and Sell Stock (0) | 2019.10.16 |
---|---|
[DP] - 53. Maximum Subarray (2) | 2019.10.10 |
[Tree] - 617 (0) | 2019.10.09 |
[Tree] [Recursion] - 938 (0) | 2019.10.08 |
[Greedy] - 1196 (0) | 2019.10.08 |