File tree 2 files changed +17
-3
lines changed
2 files changed +17
-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-215 /2081-1f425f.svg )
4
- ![ problems-solved-java] ( https://img.shields.io/badge/Java-215 /2081-1abc9c.svg )
3
+ ![ problems-solved] ( https://img.shields.io/badge/Problems%20Solved-220 /2081-1f425f.svg )
4
+ ![ problems-solved-java] ( https://img.shields.io/badge/Java-220 /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 )
255
255
| 937 | [ Reorder Data In Log Files] ( https://leetcode.com/problems/reorder-data-in-log-files ) | [ ![ Java] ( assets/java.png )] ( src/ReorderDataInLogFiles.java ) |
256
256
| 938 | [ Range Sum of BST] ( https://leetcode.com/problems/range-sum-of-bst ) | [ ![ Java] ( assets/java.png )] ( src/RangeSumOfBST.java ) |
257
257
| 941 | [ Valid Mountain Array] ( https://leetcode.com/problems/valid-mountain-array ) | |
258
- | 942 | [ DI String Match] ( https://leetcode.com/problems/di-string-match ) | |
258
+ | 942 | [ DI String Match] ( https://leetcode.com/problems/di-string-match ) | [ ![ Java ] ( assets/java.png )] ( src/DIStringMatch.java ) |
259
259
| 944 | [ Delete Columns to Make Sorted] ( https://leetcode.com/problems/delete-columns-to-make-sorted ) | |
260
260
| 949 | [ Largest Time for Given Digits] ( https://leetcode.com/problems/largest-time-for-given-digits ) | |
261
261
| 953 | [ Verifying an Alien Dictionary] ( https://leetcode.com/problems/verifying-an-alien-dictionary ) | |
Original file line number Diff line number Diff line change
1
+ public class DIStringMatch {
2
+ public int [] diStringMatch (String s ) {
3
+ int [] result = new int [s .length () + 1 ];
4
+ int current = 0 ;
5
+ for (int i = 0 ; i < s .length () ; i ++) {
6
+ if (s .charAt (i ) == 'I' ) result [i ] = current ++;
7
+ }
8
+ result [result .length - 1 ] = current ++;
9
+ for (int i = s .length () - 1 ; i >= 0 ; i --) {
10
+ if (s .charAt (i ) == 'D' ) result [i ] = current ++;
11
+ }
12
+ return result ;
13
+ }
14
+ }
You can’t perform that action at this time.
0 commit comments