Company: Visa_30may
Difficulty: medium
First Day to Reach Target Visits Problem Description You are given an array of non-negative integers, visits , which represents how many people visited a website on consecutive days. visits[0] is the number of visitors on the first day, visits[1] is the number of visitors on the second day, and so on. Your task is to return the index i of the first day when the total number of visits reaches a given target . In other words, visits[0] + visits[1] + ... + visits[i] ≥ target . If the sum of all daily visits never reaches the target , return -1 . Note: You are not expected to provide the most optimal solution, but a solution with time complexity not worse than O(visits.length 2 ) will fit within the execution time limit. Examples Example 1: Input: visits = [300, 200, 100, 200, 500], target = 700 Output: 3 Explanation: The total number of visits at the end of the first day (index 0) is 300, which is less than the given target = 700. The total number of visits at the end of the second day