java DP in 4 lines


  • 0
    R

    public int integerBreak(int n) {

        if(n==2) return 1;
        if(n==3) return 2;
        if(n==4) return 4;
        return 3 * (Math.max(n-3,integerBreak(n-3)));
        
    }

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.