
[LeetCode/easy/Simulation] Add Digits
·
알고리즘/LeetCode
https://leetcode.com/problems/add-digits/ Add Digits - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 숫자가 일의 자리일 때까지 각 자릿수를 더하는 문제 문자열을 사용해서 쉽게 더하는 방식으로 진행했다. int addDigits(int num) { string s = to_string(num); int n = 0; if(s.size() == 1) return num; do{ n = 0; for(int i=0; i 1);..