File tree Expand file tree Collapse file tree 2 files changed +44
-0
lines changed
LeetCod刷题之旅及题目解析/258.各位相加 Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Original file line number Diff line number Diff line change
1
+ ## 258. 各位相加
2
+ > https://leetcode-cn.com/problems/add-digits/
3
+
4
+
5
+ ### Java
6
+ ``` java
7
+ /*
8
+ * @Author: Goog Tech
9
+ * @Date: 2020-08-16 14:24:10
10
+ * @LastEditTime: 2020-08-16 14:25:49
11
+ * @Description: https://leetcode-cn.com/problems/add-digits/
12
+ * @FilePath: \leetcode-googtech\#258. Add Digits\Solution.java
13
+ * @WebSite: https://algorithm.show/
14
+ */
15
+
16
+ class Solution {
17
+ public int addDigits (int num ) {
18
+ if (num < 10 ) return num;
19
+ return num % 9 == 0 ? 9 : num % 9 ;
20
+ }
21
+ }
22
+ ```
23
+
24
+ ### Python
25
+ ``` python
26
+ '''
27
+ Author: Goog Tech
28
+ Date: 2020-08-16 14:25:08
29
+ LastEditTime: 2020-08-16 14:25:22
30
+ Description: https://leetcode-cn.com/problems/add-digits/
31
+ FilePath: \leetcode-googtech\#258. Add Digits\Solution.py
32
+ WebSite: https://algorithm.show/
33
+ '''
34
+
35
+ class Solution (object ):
36
+ def addDigits (self , num ):
37
+ """
38
+ :type num: int
39
+ :rtype: int
40
+ """
41
+ if num < 10 : return num
42
+ return 9 if num % 9 == 0 else num % 9
43
+ ```
Original file line number Diff line number Diff line change 55
55
* [ 232.用栈实现队列] ( LeetCod刷题之旅及题目解析/232.用栈实现队列/232.用栈实现队列.md )
56
56
* [ 234.回文链表] ( LeetCod刷题之旅及题目解析/234.回文链表/234.回文链表.md )
57
57
* [ 237.删除链表中的节点] ( LeetCod刷题之旅及题目解析/237.删除链表中的节点/237.删除链表中的节点.md )
58
+ * [ 258.各位相加] ( LeetCod刷题之旅及题目解析/258.各位相加/258.各位相加.md )
58
59
* [ 283.移动零] ( LeetCod刷题之旅及题目解析/283.移动零/283.移动零.md )
59
60
* [ 344.反转字符串] ( LeetCod刷题之旅及题目解析/344.反转字符串/344.反转字符串.md )
60
61
* [ 345.反转字符串中的元音字母] ( LeetCod刷题之旅及题目解析/345.反转字符串中的元音字母/345.反转字符串中的元音字母.md )
You can’t perform that action at this time.
0 commit comments