Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Create 0343-integer-break.py
File(s) Modified: 0343-integer-break.py
Language(s) Used: python
Submission URL: https://leetcode.com/problems/integer-break/submissions/955194149/
  • Loading branch information
pdequina authored May 22, 2023
commit ecea4ac338fd1e912c4b679f7d782e90b64e50fa
15 changes: 15 additions & 0 deletions python/0343-integer-break.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class Solution(object):
def integerBreak(self, n):
"""
:type n: int
:rtype: int
"""
if n == 2:
return 1
if n == 3:
return 2
product, temp = 1, n
while temp > 4:
product *= 3
temp -= 3
return product * temp