当前位置:网站首页>Prefix and leetcode2100. Suitable for bank robbery days
Prefix and leetcode2100. Suitable for bank robbery days
2022-07-23 12:56:00 【18 ARU】
2100. Suitable for bank robbery
analysis
The prefix and
class Solution {
public List<Integer> goodDaysToRobBank(int[] security, int time) {
int n = security.length;
int[] dp1 = new int[n];
int[] dp2 = new int[n];
dp1[0] = 0;
dp2[n-1] = 0;
for (int i = 1; i < n; i++) {
if (security[i] <= security[i-1]) {
dp1[i] = dp1[i-1] + 1;
}
}
for (int i = n -2; i >= 0; i--) {
if (security[i] <= security[i+1]) {
dp2[i] = dp2[i+1] + 1;
}
}
List<Integer> list = new ArrayList<>();
for (int i = 0; i < n; i++) {
if (dp1[i] >= time && dp2[i] >= time) {
list.add(i);
}
}
int[] ans = new int[list.size()];
for (int i = 0; i < list.size(); i++) {
ans[i] = list.get(i);
}
return list;
}
}
边栏推荐
- Unity mouse controls camera drag, rotation and zoom (simulation editor camera function)
- OSPF comprehensive experiment in hcip-mgre environment
- Super easy to use packet capturing tool tcpdump
- How many seats do you need for 1000 people to eat in 2 hours?
- 关于搭建Hybrid App所需要的基础技术一文
- Unity used trilib plug-in under URP pipeline to load model material incorrectly
- jenkins用到的插件
- C#输出斐波那契数列
- 制作本地apt源离线安装
- 学习日记——(路由与交换技术)ACL访问控制列表
猜你喜欢

Telnet 配置实例学习记录

FTP 配置实例学习记录

DHCP second experiment

Explanation of websocket protocol

Routing extension configuration of OSPF and rip

Instant messaging websocket

学习日记——(路由与交换技术)三层交换机

Eth-Trunk 配置实例学习记录

学习日记——(路由与交换技术)网络地址转换 NAT技术

C #: quick sort. If there is the same number, it will be ignored, and then continue the previous search direction to find the next number that meets the requirements for replacement
随机推荐
HCIP---HCIA知识回顾(一)
C (CSharp) wechat official account development - basic configuration
关于搭建Hybrid App所需要的基础技术一文
vlan配置实例学习记录
【无标题】
Simple use of psutil monitoring
C custom set
Unity3d+moba+ skill indicator (I)
psutil监控的简单使用
DNS domain name resolution service
Build FRPC client in NAS [super brainless]
路由与接口技术——直连网络总结
Unity3d HD rendering pipeline cannot play video on the model
静态路由原理与配置
Design experience of log file IO system
Learning diary - (routing and switching technology) layer 3 switch
Instant messaging websocket
The correspondence between the concept of go ability and the concept of software development ability
How many seats do you need for 1000 people to eat in 2 hours?
制作本地apt源离线安装