File tree 2 files changed +32
-0
lines changed
src/main/java/com/fishercoder/solutions 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ _If you like this project, please leave me a star._ ★
8
8
9
9
| # | Title | Solutions | Video | Difficulty | Tag
10
10
|------|----------------|------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------|----------------------------------|-------------
11
+ | 3006 |[Find Beautiful Indices in the Given Array I](https://leetcode.com/problems/find-beautiful-indices-in-the-given-array-i/)| [Java](../master/src/main/java/com/fishercoder/solutions/_3006.java) | | Easy |
11
12
| 2716 |[Minimize String Length](https://leetcode.com/problems/minimize-string-length/)| [Java](../master/src/main/java/com/fishercoder/solutions/_2716.java) | [:tv:](https://youtu.be/aMJ3T0K8LjI) | Easy |
12
13
| 2710 |[Remove Trailing Zeros From a String](https://leetcode.com/problems/remove-trailing-zeros-from-a-string/)| [Java](../master/src/main/java/com/fishercoder/solutions/_2710.java) | | Easy |
13
14
| 2706 |[Buy Two Chocolates](https://leetcode.com/problems/buy-two-chocolates/)| [Java](../master/src/main/java/com/fishercoder/solutions/_2706.java) | | Easy |
Original file line number Diff line number Diff line change
1
+ package com .fishercoder .solutions ;
2
+
3
+ import java .util .ArrayList ;
4
+ import java .util .List ;
5
+
6
+ public class _3006 {
7
+ public static class Solution1 {
8
+ public List <Integer > beautifulIndices (String s , String a , String b , int k ) {
9
+ List <Integer > aIndices = new ArrayList <>();
10
+ List <Integer > bIndices = new ArrayList <>();
11
+ for (int i = 0 ; i < s .length (); i ++) {
12
+ if ((i + a .length ()) <= s .length () && s .substring (i , i + a .length ()).equals (a )) {
13
+ aIndices .add (i );
14
+ }
15
+ if ((i + b .length ()) <= s .length () && s .substring (i , i + b .length ()).equals (b )) {
16
+ bIndices .add (i );
17
+ }
18
+ }
19
+ List <Integer > result = new ArrayList <>();
20
+ for (int aIndex : aIndices ) {
21
+ for (int bIndex : bIndices ) {
22
+ if (Math .abs (aIndex - bIndex ) <= k ) {
23
+ result .add (aIndex );
24
+ break ;
25
+ }
26
+ }
27
+ }
28
+ return result ;
29
+ }
30
+ }
31
+ }
You can’t perform that action at this time.
0 commit comments