Home
Topics
Practice
Roadmap
DSA Tracker
Code Editor
Tech Blogs
More
Sign in
Get started
Loading question...
Feedback
Integer Break
Medium
00:00
0 users online
Share
Description
Solution
Submissions
Discussion
Given a positive integer n, break it into the sum of at least two positive integers to maximize the product.
Sample Input:
2
Sample Output:
1
Hints
Hint 1
Use dynamic programming
Hint 2
DP[i] = max(j * (i-j), j * DP[i-j]) for all j < i
Hint 3
Mathematical solution: break into 3s as much as possible
Code Editor
Reset
Run
Save
Loading...