c++ Programming Glossary: digit_sum
Interview Question: Optimal Solution to the problem of finding Heavy integers http://stackoverflow.com/questions/7136590/interview-question-optimal-solution-to-the-problem-of-finding-heavy-integers sum of the digits and computes the number of digits size_t digit_sum size_t n size_t numDigits if n 0 return 0 size_t digSum 0 sum.. between d and d n start end for size_t i start i end i if digit_sum i numDigits HEAVY_AVG numDigits cout i numHeavy printf n.. HEAVY_AVG numDigits cout i numHeavy printf n Naive digit_sum computed d times and total heavy numbers d n end start 1 numHeavy..
|