File tree 2 files changed +17
-0
lines changed
2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change 205
205
237|[ Delete Node in a Linked List] ( ./0237-delete-node-in-a-linked-list.js ) |Easy|
206
206
238|[ Product of Array Except Self] ( ./0238-product-of-array-except-self.js ) |Medium|
207
207
242|[ Valid Anagram] ( ./0242-valid-anagram.js ) |Easy|
208
+ 258|[ Add Digits] ( ./0258-add-digits.js ) |Easy|
208
209
260|[ Single Number III] ( ./0260-single-number-iii.js ) |Medium|
209
210
263|[ Ugly Number] ( ./0263-ugly-number.js ) |Easy|
210
211
264|[ Ugly Number II] ( ./0264-ugly-number-ii.js ) |Medium|
Original file line number Diff line number Diff line change
1
+ /**
2
+ * 258. Add Digits
3
+ * https://leetcode.com/problems/add-digits/
4
+ * Difficulty: Easy
5
+ *
6
+ * Given an integer num, repeatedly add all its digits until
7
+ * the result has only one digit, and return it.
8
+ */
9
+
10
+ /**
11
+ * @param {number } num
12
+ * @return {number }
13
+ */
14
+ var addDigits = function ( num ) {
15
+ return num < 10 ? num : num % 9 === 0 ? 9 : num % 9 ;
16
+ } ;
You can’t perform that action at this time.
0 commit comments