Leetcode Solutions: Sum of Digits in the Minimum Number

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.

def getMin(arr):
s = str(min(arr))
total = 0

for c in s:
total += int(c)

return 0 …


This content originally appeared on DEV Community and was authored by SalahElhossiny

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.

def getMin(arr):
    s = str(min(arr))
    total = 0

    for c in s:
        total += int(c)

    return 0 if total % 2 != 0 else 1


print(getMin([99,77,33,66,55]))


This content originally appeared on DEV Community and was authored by SalahElhossiny


Print Share Comment Cite Upload Translate Updates
APA

SalahElhossiny | Sciencx (2022-07-10T10:16:19+00:00) Leetcode Solutions: Sum of Digits in the Minimum Number. Retrieved from https://www.scien.cx/2022/07/10/leetcode-solutions-sum-of-digits-in-the-minimum-number/

MLA
" » Leetcode Solutions: Sum of Digits in the Minimum Number." SalahElhossiny | Sciencx - Sunday July 10, 2022, https://www.scien.cx/2022/07/10/leetcode-solutions-sum-of-digits-in-the-minimum-number/
HARVARD
SalahElhossiny | Sciencx Sunday July 10, 2022 » Leetcode Solutions: Sum of Digits in the Minimum Number., viewed ,<https://www.scien.cx/2022/07/10/leetcode-solutions-sum-of-digits-in-the-minimum-number/>
VANCOUVER
SalahElhossiny | Sciencx - » Leetcode Solutions: Sum of Digits in the Minimum Number. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/07/10/leetcode-solutions-sum-of-digits-in-the-minimum-number/
CHICAGO
" » Leetcode Solutions: Sum of Digits in the Minimum Number." SalahElhossiny | Sciencx - Accessed . https://www.scien.cx/2022/07/10/leetcode-solutions-sum-of-digits-in-the-minimum-number/
IEEE
" » Leetcode Solutions: Sum of Digits in the Minimum Number." SalahElhossiny | Sciencx [Online]. Available: https://www.scien.cx/2022/07/10/leetcode-solutions-sum-of-digits-in-the-minimum-number/. [Accessed: ]
rf:citation
» Leetcode Solutions: Sum of Digits in the Minimum Number | SalahElhossiny | Sciencx | https://www.scien.cx/2022/07/10/leetcode-solutions-sum-of-digits-in-the-minimum-number/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.