My Java Solution


  • 0
    C
    public class Solution {
        public int addDigits(int num) {
            if (num < 0)
                return -1;
            if (num == 0)
                return 0;
            if (num % 9 == 0)
                return 9;
            else
                return num%9;
            
        }
    }

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.