Day 3: Buying Chocolate Boxes
medium
You are at a store where there are N boxes of chocolates placed in a row. Each box contains a positive number of chocolates (no empty box).
You want to buy a group of consecutive boxes such that the total number of chocolates is exactly K. Among all such possible groups, you want the minimum number of boxes.
NOTE: If there is no such group, return −1. Input Format:
First line: Two integers N — number of boxes (1≤N≤105) and K — number of required chocolates (1≤K≤1018)
Second line: N integers — number of chocolates in ith box, A[1],A[2],…,A[N] (1≤A[i]≤1013) Output Format:
Print a single integer: the minimum number of consecutive boxes whose total number of chocolates is exactly K.
If no such group exists, print −1. Constraints:
(1≤N≤105)
(1≤K≤1018)
(1≤A[i]≤1013) Examples: