Skip to content

Commit a56adcf

Browse files
committed
Create add-digits.cpp
1 parent a5a5f73 commit a56adcf

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

C++/add-digits.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Time: O(1)
2+
// Space: O(1)
3+
4+
class Solution {
5+
public:
6+
int addDigits(int num) {
7+
return (num - 1) % 9 + 1;
8+
}
9+
};

0 commit comments

Comments
 (0)