Skip to content

Commit 7a8da22

Browse files
authored
perf: optimize solutions to lc problem: No.2100 (#737)
No.2100.Find Good Days to Rob the Bank
1 parent 2e7d632 commit 7a8da22

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

solution/2100-2199/2100.Find Good Days to Rob the Bank/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ class Solution {
122122
}
123123
}
124124
List<Integer> ans = new ArrayList<>();
125-
for (int i = 0; i < n; ++i) {
125+
for (int i = time; i < n - time; ++i) {
126126
if (time <= Math.min(left[i], right[i])) {
127127
ans.add(i);
128128
}
@@ -149,7 +149,7 @@ public:
149149
if (security[i] <= security[i + 1])
150150
right[i] = right[i + 1] + 1;
151151
vector<int> ans;
152-
for (int i = 0; i < n; ++i)
152+
for (int i = time; i < n - time; ++i)
153153
if (time <= min(left[i], right[i]))
154154
ans.push_back(i);
155155
return ans;
@@ -178,7 +178,7 @@ func goodDaysToRobBank(security []int, time int) []int {
178178
}
179179
}
180180
var ans []int
181-
for i := 0; i < n; i++ {
181+
for i := time; i < n - time; i++ {
182182
if time <= left[i] && time <= right[i] {
183183
ans = append(ans, i)
184184
}

solution/2100-2199/2100.Find Good Days to Rob the Bank/README_EN.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ class Solution {
110110
}
111111
}
112112
List<Integer> ans = new ArrayList<>();
113-
for (int i = 0; i < n; ++i) {
113+
for (int i = time; i < n - time; ++i) {
114114
if (time <= Math.min(left[i], right[i])) {
115115
ans.add(i);
116116
}
@@ -137,7 +137,7 @@ public:
137137
if (security[i] <= security[i + 1])
138138
right[i] = right[i + 1] + 1;
139139
vector<int> ans;
140-
for (int i = 0; i < n; ++i)
140+
for (int i = time; i < n - time; ++i)
141141
if (time <= min(left[i], right[i]))
142142
ans.push_back(i);
143143
return ans;
@@ -166,7 +166,7 @@ func goodDaysToRobBank(security []int, time int) []int {
166166
}
167167
}
168168
var ans []int
169-
for i := 0; i < n; i++ {
169+
for i := time; i < n - time; i++ {
170170
if time <= left[i] && time <= right[i] {
171171
ans = append(ans, i)
172172
}

solution/2100-2199/2100.Find Good Days to Rob the Bank/Solution.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class Solution {
1212
if (security[i] <= security[i + 1])
1313
right[i] = right[i + 1] + 1;
1414
vector<int> ans;
15-
for (int i = 0; i < n; ++i)
15+
for (int i = tiem; i < n - time; ++i)
1616
if (time <= min(left[i], right[i]))
1717
ans.push_back(i);
1818
return ans;

solution/2100-2199/2100.Find Good Days to Rob the Bank/Solution.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ func goodDaysToRobBank(security []int, time int) []int {
1616
}
1717
}
1818
var ans []int
19-
for i := 0; i < n; i++ {
19+
for i := time; i < n - time; i++ {
2020
if time <= left[i] && time <= right[i] {
2121
ans = append(ans, i)
2222
}

solution/2100-2199/2100.Find Good Days to Rob the Bank/Solution.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public List<Integer> goodDaysToRobBank(int[] security, int time) {
1717
}
1818
}
1919
List<Integer> ans = new ArrayList<>();
20-
for (int i = 0; i < n; ++i) {
20+
for (int i = time; i < n - time; ++i) {
2121
if (time <= Math.min(left[i], right[i])) {
2222
ans.add(i);
2323
}

0 commit comments

Comments
 (0)