File tree Expand file tree Collapse file tree 2 files changed +12
-6
lines changed
solution/3000-3099/3008.Find Beautiful Indices in the Given Array II Expand file tree Collapse file tree 2 files changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -154,7 +154,8 @@ public class Solution {
154
154
}
155
155
156
156
if (j == M ) {
157
- result. add(i - j); // Pattern found at index i-j+1 (If you have to return 1 Based indexing, that's why added + 1)
157
+ result. add(i - j); // Pattern found at index i-j+1 (If you have to return 1 Based
158
+ // indexing, that's why added + 1)
158
159
j = lps[j - 1 ];
159
160
} else if (i < N && pat. charAt(j) != txt. charAt(i)) {
160
161
if (j != 0 ) {
@@ -196,11 +197,13 @@ public class Solution {
196
197
for (int i : i_indices) {
197
198
198
199
int left_limit = Math . max(0 , i - k); // To avoid out of bound -> I used max(0, i-k)
199
- int right_limit = Math . min(n - 1 , i + k); // To avoid out of bound -> I used min(n-1, i+k)
200
+ int right_limit
201
+ = Math . min(n - 1 , i + k); // To avoid out of bound -> I used min(n-1, i+k)
200
202
201
203
int lowerBoundIndex = lowerBound(j_indices, left_limit);
202
204
203
- if (lowerBoundIndex < j_indices. size() && j_indices. get(lowerBoundIndex) <= right_limit) {
205
+ if (lowerBoundIndex < j_indices. size()
206
+ && j_indices. get(lowerBoundIndex) <= right_limit) {
204
207
result. add(i);
205
208
}
206
209
}
Original file line number Diff line number Diff line change @@ -152,7 +152,8 @@ public class Solution {
152
152
}
153
153
154
154
if (j == M ) {
155
- result. add(i - j); // Pattern found at index i-j+1 (If you have to return 1 Based indexing, that's why added + 1)
155
+ result. add(i - j); // Pattern found at index i-j+1 (If you have to return 1 Based
156
+ // indexing, that's why added + 1)
156
157
j = lps[j - 1 ];
157
158
} else if (i < N && pat. charAt(j) != txt. charAt(i)) {
158
159
if (j != 0 ) {
@@ -194,11 +195,13 @@ public class Solution {
194
195
for (int i : i_indices) {
195
196
196
197
int left_limit = Math . max(0 , i - k); // To avoid out of bound -> I used max(0, i-k)
197
- int right_limit = Math . min(n - 1 , i + k); // To avoid out of bound -> I used min(n-1, i+k)
198
+ int right_limit
199
+ = Math . min(n - 1 , i + k); // To avoid out of bound -> I used min(n-1, i+k)
198
200
199
201
int lowerBoundIndex = lowerBound(j_indices, left_limit);
200
202
201
- if (lowerBoundIndex < j_indices. size() && j_indices. get(lowerBoundIndex) <= right_limit) {
203
+ if (lowerBoundIndex < j_indices. size()
204
+ && j_indices. get(lowerBoundIndex) <= right_limit) {
202
205
result. add(i);
203
206
}
204
207
}
You can’t perform that action at this time.
0 commit comments