about | help | code help+videos | done | prefs |
Write a method that returns the sum of specific digits in the array of positive integers. The specific digits to use depends on where the number is positioned in the array. Use the ones place digit in the number in the first position in the array. Use the tens place digit in the next number, the hundreds place digit in the next number, and so on. For example, if the array is {523,7182,1054,9876} you would return 20 because 3+8+0+9=20. Make sure you see where each of these values that are being added came from. In some cases, you might need a digit in a position beyond the size of the number. For example, 178 does not have a thousands or ten-thousands place, but you may need one of these place values. In that case, the place value is zero. So you can think of numbers as having an infinite number of leading zeros. Look at the test data for other examples. test2024_10_08_SLHL_sumDigitsPlaces([241, 4, 5, 9, 3, 7]) → 1 test2024_10_08_SLHL_sumDigitsPlaces([52]) → 2 test2024_10_08_SLHL_sumDigitsPlaces([781, 943]) → 5 ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 290
Copyright Nick Parlante 2017 - privacy