what's wrong with my opinion?


  • 0
    A

    public class Solution {
    public int minSubArrayLen(int s, int[] nums) {
    if(nums.length==0||nums==null)
    return 0;
    Arrays.sort(nums);
    if(nums[0]>=s)
    return 1;
    for(int i=0;i<nums.length;i++){
    if(nums[i]>=s)
    return 1;
    }
    int total=0;
    for(int i=0;i<nums.length;i++){
    total+=nums[i];
    }
    if(total<s)
    return 0;
    total=0;
    int count=0;
    for(int i=nums.length-1;i>=0;i--){
    total+=nums[i];
    count++;
    if(total>=s)
    break;
    }
    return count;
    }
    }


Log in to reply
 

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