One line Java Solution using formula from wiki

  • 0

    I saw the formula from wiki, which is the hint 4, so just use it. And it works!!

    public class AddDigits {
    	public int addDigits(int num) {
    		return num - 9 * ((num - 1) / 9);

Log in to reply

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