You are viewing a single comment's thread. Return to all comments →
java solution o(1) public static int superDigit(String n, int k) {
if (n == null) return 0; if (k == 0) { return suberDigit(data); } long data = Long.valueOf(n); int i = suberDigit(data); int res = i * k; if (res <= 9) { return res; } return suberDigit(res); } static int suberDigit(long data) { if (data == 0) { return 0; } if (data % 9 == 0) { return 9; } else { return (int) (data % 9); } }
Seems like cookies are disabled on this browser, please enable them to open this website
Super Digit
You are viewing a single comment's thread. Return to all comments →
java solution o(1) public static int superDigit(String n, int k) {