Solución
solution.tsTypeScript
public class Solution {
public int sumAlternateDigits(int n) {
int temp = n;
int divider = 1;
while (temp >= 10){
divider *=10;
temp /=10;
}
int sum = 0;
boolean getDigit = true;
while (divider > 0){
int digit = n / divider ;
if (getDigit){
sum += digit;
}
getDigit = !getDigit;
n %= divider;
divider /= 10;
}
// Escribe tu solución aquí
return sum;
}
}0respuestas