Simple Easy Cpp Solution


  • 0
    K

    class Solution {

    public:

    int integerBreak(int n) {
        int prod=1;
        if(n==1 || n==2)
            return prod;
        if(n==3)
            return 2;
        while(n>=3){
            if(n==4){
                prod = prod *4;
                n-=4;
                break;
            }
            prod = prod*3;
            n-=3;
        }
        if(n==2){
            prod = prod * 2;
        }
        return prod;
    }
    

    };


Log in to reply
 

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