Guest User

Untitled

a guest
May 23rd, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. class Solution {
  2. public:
  3.  
  4. int add(int num){
  5. int ans = 0;
  6. while(num > 0){
  7. ans += num%10;
  8. num /= 10;
  9. }
  10. return ans;
  11. }
  12.  
  13. int addDigits(int num) {
  14. queue<int> q;
  15.  
  16. while(num >= 10){
  17. num = add(num);
  18. }
  19.  
  20. return num;
  21. }
  22. };
Add Comment
Please, Sign In to add comment