Find Good Days to Rob the Bank
You and a gang of thieves are planning on robbing a bank. You are given a 0-indexed integer array security, where security[i] is the number of guards on duty on the i^th day. The days are numbered starting from 0. You are also given an integer time.
The i^th day is a good day to rob the bank if:
- There are at least
timedays before and after thei^thday. - The number of guards at the bank for the
timedays beforeiare non-increasing. - The number of guards at the bank for the
timedays afteriare non-decreasing.
More formally, this means day i is a good day to rob the bank if and only if security[i - time] >= security[i - time + 1] >= ... >= security[i] <= ... <= security[i + time - 1] <= security[i + time].
Return a list of all days (0-indexed) that are good days to rob the bank. The order that the days are returned in does not matter.
security = [5,3,3,3,5,6,2], time = 2[2,3]security = [1,1,1,1,1], time = 0[0,1,2,3,4]Constraints
- 1 <= security.length <= 10^5
- 0 <= security[i], time <= 10^5