public int candy(int[] ratings) {
        if(ratings == null || ratings.length == 0) return 0;
        if(ratings.length == 1) return 1;

        int L = ratings.length;
        // int [] candies = new int [L];

//        Arrays.fill(candies, 1);
        int res = L;
        for(int i = 1; i < L; ++i){
            if(ratings[i] > ratings[i-1]) ++res;
        }

        for(int i = L - 1; i >= 1; --i){
            if(ratings[i-1] > ratings[i]) ++res;
        }

        // int res = 0;
        // for(int i = 0; i < L; ++i) res += candies[i];
        return res;
    }