File tree 2 files changed +22
-3
lines changed
2 files changed +22
-3
lines changed Original file line number Diff line number Diff line change 1
1
# LeetCode Algorithms
2
2
3
- ![ problems-solved] ( https://img.shields.io/badge/Problems%20Solved-192 /2081-1f425f.svg )
4
- ![ problems-solved-java] ( https://img.shields.io/badge/Java-192 /2081-1abc9c.svg )
3
+ ![ problems-solved] ( https://img.shields.io/badge/Problems%20Solved-193 /2081-1f425f.svg )
4
+ ![ problems-solved-java] ( https://img.shields.io/badge/Java-193 /2081-1abc9c.svg )
5
5
![ problems-solved-python] ( https://img.shields.io/badge/Python-186/2081-1abc9c.svg )
6
6
[ ![ PRs Welcome] ( https://img.shields.io/badge/PRs-welcome-brightgreen.svg )] ( CONTRIBUTING.md )
7
7
[ ![ cp] ( https://img.shields.io/badge/also%20see-Competitve%20Programming-1f72ff.svg )] ( https://github.com/anishLearnsToCode/competitive-programming )
223
223
| 819 | [ Most Common Word] ( https://leetcode.com/problems/most-common-word ) | [ ![ Java] ( assets/java.png )] ( src/MostCommonWord.java ) |
224
224
| 821 | [ Shortest Distance to Character] ( https://leetcode.com/problems/shortest-distance-to-a-character ) | [ ![ Java] ( assets/java.png )] ( src/ShortestDistanceToACharacter.java ) |
225
225
| 824 | [ Goat Latin] ( https://leetcode.com/problems/goat-latin ) | [ ![ Java] ( assets/java.png )] ( src/GoatLatin.java ) |
226
- | 830 | [ Positions of Large Groups] ( https://leetcode.com/problems/positions-of-large-groups ) | |
226
+ | 830 | [ Positions of Large Groups] ( https://leetcode.com/problems/positions-of-large-groups ) | [ ![ Java ] ( assets/java.png )] ( src/PositionsOfLargeGroups.java ) |
227
227
| 832 | [ Flipping an Image] ( https://leetcode.com/problems/flipping-an-image ) | |
228
228
| 836 | [ Rectangle Overlap] ( https://leetcode.com/problems/rectangle-overlap ) | |
229
229
| 840 | [ Magic Squares in Grid] ( https://leetcode.com/problems/magic-squares-in-grid ) | |
Original file line number Diff line number Diff line change
1
+ import java .util .ArrayList ;
2
+ import java .util .List ;
3
+
4
+ public class PositionsOfLargeGroups {
5
+ public List <List <Integer >> largeGroupPositions (String s ) {
6
+ List <List <Integer >> result = new ArrayList <>();
7
+ char current = s .charAt (0 );
8
+ int start = 0 ;
9
+ for (int index = 1 ; index < s .length () ; index ++) {
10
+ if (s .charAt (index ) != current ) {
11
+ if (index - start >= 3 ) result .add (List .of (start , index - 1 ));
12
+ start = index ;
13
+ current = s .charAt (index );
14
+ }
15
+ }
16
+ if (s .length () - start >= 3 ) result .add (List .of (start , s .length () - 1 ));
17
+ return result ;
18
+ }
19
+ }
You can’t perform that action at this time.
0 commit comments