Tap here to switch tabs
Problem
Submissions

Problem: Find Good Days to Rob the Bank

med
30 min
Try to solve the Find Good Days to Rob the Bank problem.

Statement

You are given a 00-indexed integer array security, where security[i] represents the number of security guards on duty on the iextthi^{ ext{th}} day, and an integer time.

The iextthi^{ ext{th}} day is considered a good day to rob the bank if all of the following conditions are met:

  • There are at least time days before and after day i. That is, time ≤i<\leq i < security.length −- time.

  • The number of security guards is non-increasing for the time days before day i. That is, security[i - time] \ge security[i - time + 1] \ge \dots \ge security[i].

  • The number of security guards is non-decreasing for the time days after day i. That is, security[i] \le security[i + 1] \le \dots \le security[i + time].

Return an array of all good days to rob the bank. The order of the returned days does not matter.

Constraints:

  • 1≤1 \le security.length ≤105\le 10^5

  • 0≤0 \le security[i], time ≤105\le 10^5

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Find Good Days to Rob the Bank

med
30 min
Try to solve the Find Good Days to Rob the Bank problem.

Statement

You are given a 00-indexed integer array security, where security[i] represents the number of security guards on duty on the iextthi^{ ext{th}} day, and an integer time.

The iextthi^{ ext{th}} day is considered a good day to rob the bank if all of the following conditions are met:

  • There are at least time days before and after day i. That is, time ≤i<\leq i < security.length −- time.

  • The number of security guards is non-increasing for the time days before day i. That is, security[i - time] \ge security[i - time + 1] \ge \dots \ge security[i].

  • The number of security guards is non-decreasing for the time days after day i. That is, security[i] \le security[i + 1] \le \dots \le security[i + time].

Return an array of all good days to rob the bank. The order of the returned days does not matter.

Constraints:

  • 1≤1 \le security.length ≤105\le 10^5

  • 0≤0 \le security[i], time ≤105\le 10^5