Add Digits

 https://leetcode.com/problems/add-digits/

 

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

Comments

Popular posts from this blog

Perfect Peak of Array

Is Rectangle?

Sort array with squares!