File tree Expand file tree Collapse file tree 3 files changed +40
-0
lines changed
main/java/com/fishercoder/solutions
test/java/com/fishercoder Expand file tree Collapse file tree 3 files changed +40
-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
+ | 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 |
11
12
| 2696 |[Minimum String Length After Removing Substrings](https://leetcode.com/problems/minimum-string-length-after-removing-substrings/)| [Java](../master/src/main/java/com/fishercoder/solutions/_2696.java) | | Easy |
12
13
| 2670 |[Find the Distinct Difference Array](https://leetcode.com/problems/find-the-distinct-difference-array/)| [Java](../master/src/main/java/com/fishercoder/solutions/_2670.java) | | Easy |
13
14
| 2596 |[Check Knight Tour Configuration](https://leetcode.com/problems/check-knight-tour-configuration/)| [Java](../master/src/main/java/com/fishercoder/solutions/_2596.java) | [:tv:](https://youtu.be/OBht8NT_09c) | Medium |
Original file line number Diff line number Diff line change
1
+ package com .fishercoder .solutions ;
2
+
3
+ public class _2710 {
4
+ public static class Solution1 {
5
+ public String removeTrailingZeros (String num ) {
6
+ StringBuilder sb = new StringBuilder ();
7
+ boolean trailing = true ;
8
+ for (int i = num .length () - 1 ; i >= 0 ; i --) {
9
+ if (num .charAt (i ) != '0' || !trailing ) {
10
+ sb .append (num .charAt (i ));
11
+ trailing = false ;
12
+ }
13
+ }
14
+ return sb .reverse ().toString ();
15
+ }
16
+ }
17
+ }
Original file line number Diff line number Diff line change
1
+ package com .fishercoder ;
2
+
3
+ import com .fishercoder .solutions ._2710 ;
4
+ import org .junit .BeforeClass ;
5
+ import org .junit .Test ;
6
+
7
+ import static org .junit .Assert .assertEquals ;
8
+
9
+ public class _2710Test {
10
+ private static _2710 .Solution1 solution1 ;
11
+
12
+ @ BeforeClass
13
+ public static void setup () {
14
+ solution1 = new _2710 .Solution1 ();
15
+ }
16
+
17
+ @ Test
18
+ public void test1 () {
19
+ assertEquals ("512301" , solution1 .removeTrailingZeros ("51230100" ));
20
+ }
21
+
22
+ }
You can’t perform that action at this time.
0 commit comments