File tree Expand file tree Collapse file tree 3 files changed +50
-0
lines changed Expand file tree Collapse file tree 3 files changed +50
-0
lines changed Original file line number Diff line number Diff line change 192
192
| 994 | Rotting Oranges | Medium | O(N^2) | O(N) | Trees, Recursion | | |
193
193
| 1004 | Max Consecutive Ones III | Medium | O(N) | O(1) | Sliding Window, Two Pointers | | |
194
194
| 1007 | Minimum Domino Rotations For Equal Row | Medium | O(N) | O(1) | Array, Greedy | | |
195
+ | 1015 | Smallest Integer Divisible by K | Medium | O(K) | O(K) | Math | | |
195
196
| 1022 | Sum of Root To Leaf Binary Numbers | Easy | O(N) | O(H) | Tree | | |
196
197
| 1026 | Maximum Difference Between Node and Ancestor | Medium | O(N) | O(H) | Tree, DFS | | |
197
198
| 1029 | Two City Scheduling | Easy | O(NlogN) | O(N) | Greedy | Good Problem | |
Original file line number Diff line number Diff line change
1
+ #
2
+ # @lc app=leetcode id=1015 lang=python3
3
+ #
4
+ # [1015] Smallest Integer Divisible by K
5
+ #
6
+
7
+ # @lc code=start
8
+ # TAGS: Math
9
+ # REVIEWME: Math
10
+ class Solution :
11
+ # 48 ms, 76.4%. Time: O(K). Space: O(K)
12
+ def smallestRepunitDivByK (self , K : int ) -> int :
13
+ visited = set ()
14
+ cnt = rem = 0
15
+ while 1 :
16
+ cnt += 1
17
+ rem = (rem * 10 + 1 ) % K
18
+ if rem in visited : return - 1
19
+ visited .add (rem )
20
+ if rem == 0 : return cnt
21
+
22
+ # @lc code=end
23
+
Original file line number Diff line number Diff line change
1
+ 1
2
+ 2
3
+ 3
4
+ 4
5
+ 5
6
+ 6
7
+ 7
8
+ 8
9
+ 9
10
+ 10
11
+ 11
12
+ 12
13
+ 13
14
+ 14
15
+ 15
16
+ 16
17
+ 17
18
+ 18
19
+ 19
20
+ 20
21
+ 21
22
+ 22
23
+ 23
24
+ 24
25
+ 25
26
+ 26
You can’t perform that action at this time.
0 commit comments