본문 바로가기

Problem Solving/리트코드(leetcode)

Add Digits

class Solution {
public:
    int addDigits(int num) {
        return num != 0 && num % 9 == 0 ? 9 : num % 9;
    }
};

'Problem Solving > 리트코드(leetcode)' 카테고리의 다른 글

Power of Four  (0) 2022.01.16
Lemonade Change  (0) 2022.01.16
Summary Ranges  (0) 2022.01.16
Single Number  (0) 2022.01.16
Count Primes  (0) 2022.01.16