Most intutive solution with branch cut


  • 0
    S
    static int numOfSubArray(int[] nums, int k) {
    		int cnt = 0;
    		boolean flag;
    		for (int i = 0; i < nums.length; i++) {
    			flag = false;
    			int product = 1;
    			for (int j = i; j < nums.length; j++) {
    				product *= nums[j];
    				if (product >= k) {
    					flag = true;
    					break;
    				}
    				cnt++;
    			}
    			if (flag) continue;	
    		}
    		return cnt;
    	}

Log in to reply
 

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