FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
LeetCode-Solutions/Python/factor-combinations.py at master · Monika-R/LeetCode-Solutions · GitHub
Monika-R
/
LeetCode-Solutions
Public
forked from
kamyu104/LeetCode-Solutions
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
LeetCode-Solutions
/
Python
/
factor-combinations.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
24 lines (21 loc) · 645 Bytes
Breadcrumbs
LeetCode-Solutions
/
Python
/
factor-combinations.py
Copy path
File metadata and controls
24 lines (21 loc) · 645 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Time: O(nlogn)
# Space: O(logn)
class
Solution
(
object
):
# @param {integer} n
# @return {integer[][]}
def
getFactors
(
self
,
n
):
result
=
[]
factors
=
[]
self
.
getResult
(
n
,
result
,
factors
)
return
result
def
getResult
(
self
,
n
,
result
,
factors
):
i
=
2
if
not
factors
else
factors
[
-
1
]
while
i
<=
n
/
i
:
if
n
%
i
==
0
:
factors
.
append
(
i
)
factors
.
append
(
n
/
i
)
result
.
append
(
list
(
factors
))
factors
.
pop
()
self
.
getResult
(
n
/
i
,
result
,
factors
)
factors
.
pop
()
i
+=
1
Back
|
FazBrowse Home
|
New Git URL