category-wise-problems

contains category wise problems(data structures, competitive) of popular platforms.

View the Project on GitHub mayankdutta/category-wise-problems

2100. Find Good Days to Rob the Bank, medium, prefix sums

Code ```cpp vector goodDaysToRobBank(vector &security, int time) { int n = security.size(); vector prefix(n, 0), suffix(n, 0); for (int i = 1; i < n; i++) if (security[i] <= security[i - 1]) prefix[i] = prefix[i - 1] + 1; for (int i = n - 2; i >= 0; i--) if (security[i] <= security[i + 1]) suffix[i] = suffix[i + 1] + 1; vector ans; for (int i = 0; i < n; i++) if (prefix[i] >= time && suffix[i] >= time) ans.push_back(i); return ans; } ``` </details>