Class Solution
java.lang.Object
g2001_2100.s2100_find_good_days_to_rob_the_bank.Solution
2100 - Find Good Days to Rob the Bank.<p>Medium</p>
<p>You and a gang of thieves are planning on robbing a bank. You are given a <strong>0-indexed</strong> integer array <code>security</code>, where <code>security[i]</code> is the number of guards on duty on the <code>i<sup>th</sup></code> day. The days are numbered starting from <code>0</code>. You are also given an integer <code>time</code>.</p>
<p>The <code>i<sup>th</sup></code> day is a good day to rob the bank if:</p>
<ul>
<li>There are at least <code>time</code> days before and after the <code>i<sup>th</sup></code> day,</li>
<li>The number of guards at the bank for the <code>time</code> days <strong>before</strong> <code>i</code> are <strong>non-increasing</strong> , and</li>
<li>The number of guards at the bank for the <code>time</code> days <strong>after</strong> <code>i</code> are <strong>non-decreasing</strong>.</li>
</ul>
<p>More formally, this means day <code>i</code> is a good day to rob the bank if and only if <code>security[i - time] >= security[i - time + 1] >= ... >= security[i] <= ... <= security[i + time - 1] <= security[i + time]</code>.</p>
<p>Return <em>a list of <strong>all</strong> days <strong>(0-indexed)</strong> that are good days to rob the bank</em>. <em>The order that the days are returned in does <strong>not</strong> matter.</em></p>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> security = [5,3,3,3,5,6,2], time = 2</p>
<p><strong>Output:</strong> [2,3]</p>
<p><strong>Explanation:</strong></p>
<p>On day 2, we have security[0] >= security[1] >= security[2] <= security[3] <= security[4].</p>
<p>On day 3, we have security[1] >= security[2] >= security[3] <= security[4] <= security[5].</p>
<p>No other days satisfy this condition, so days 2 and 3 are the only good days to rob the bank.</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> security = [1,1,1,1,1], time = 0</p>
<p><strong>Output:</strong> [0,1,2,3,4]</p>
<p><strong>Explanation:</strong> Since time equals 0, every day is a good day to rob the bank, so return every day.</p>
<p><strong>Example 3:</strong></p>
<p><strong>Input:</strong> security = [1,2,3,4,5,6], time = 2</p>
<p><strong>Output:</strong> []</p>
<p><strong>Explanation:</strong></p>
<p>No day has 2 days before it that have a non-increasing number of guards.</p>
<p>Thus, no day is a good day to rob the bank, so return an empty list.</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 <= security.length <= 10<sup>5</sup></code></li>
<li><code>0 <= security[i], time <= 10<sup>5</sup></code></li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
goodDaysToRobBank
-