2 line JAVA 0ms solution


  • -1
    A
    public class Solution {
        public int integerBreak(int n) {
       
             if(n<=3)return n-1;
           
             return n%3==1?(int)Math.pow(3,((n/3)-1))*4:(int)Math.pow(3,(n/3))*((n%3==0?1:2));
        }
    }
    

Log in to reply
 

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