• + 1 comment
    public static int birthday(List<Integer> s, int d, int m) {
        // Write your code here
            int result = 0;
            int count = 0;
            int i = 0;
            boolean isFinished = false;
            while (!isFinished) {
                if(s.size() == 1 && s.get(i) == d) {
                    result = result + 1;
                    isFinished = true;
                }
                count = s.get(i);
                for(int j = i + 1; j < i + m; j++) {
                    count = count + s.get(j);
                    System.out.println(j);
                    if((j + 1) == s.size()) {
                        isFinished = true;
                    }
                }
                if(count == d && s.size() != 1) {
                    result = result + 1;
                }
                i++;
            }        
            
            return result;
    
        }
    
    }