Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit228e78f

Browse files
[LEET-3349] add 3349
1 parent2548c18 commit228e78f

File tree

3 files changed

+75
-0
lines changed
  • paginated_contents/algorithms/4th_thousand
  • src

3 files changed

+75
-0
lines changed

‎paginated_contents/algorithms/4th_thousand/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
| # | Title | Solutions | Video | Difficulty | Tag
22
|------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------|------------|----------------------------------------------------------------------
3+
| 3349|[Adjacent Increasing Subarrays Detection I](https://leetcode.com/problems/adjacent-increasing-subarrays-detection-i/)|[Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3349.java)|| Easy|
34
| 3340|[Check Balanced String](https://leetcode.com/problems/check-balanced-string/)|[Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3340.java)|| Easy|
45
| 3330|[Find the Original Typed String I](https://leetcode.com/problems/find-the-original-typed-string-i/)|[Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3330.java)|| Easy|
56
| 3324|[Find the Sequence of Strings Appeared on the Screen](https://leetcode.com/problems/find-the-sequence-of-strings-appeared-on-the-screen/)|[Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3324.java)|| Easy|
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
packagecom.fishercoder.solutions.fourththousand;
2+
3+
importjava.util.List;
4+
5+
publicclass_3349 {
6+
publicstaticclassSolution1 {
7+
publicbooleanhasIncreasingSubarrays(List<Integer>nums,intk) {
8+
for (inti =0;i <nums.size();i++) {
9+
intcount =1;
10+
intj =i;
11+
booleanpossible =true;
12+
for (;j +1 <nums.size() &&count++ <k;j++) {
13+
if (nums.get(j +1) <=nums.get(j)) {
14+
possible =false;
15+
break;
16+
}
17+
}
18+
booleanpossibleAgain =true;
19+
j++;
20+
if (possible) {
21+
count =1;
22+
for (;j +1 <nums.size() &&count++ <k;j++) {
23+
if (nums.get(j +1) <=nums.get(j)) {
24+
possibleAgain =false;
25+
break;
26+
}
27+
}
28+
if (count <k) {
29+
possibleAgain =false;
30+
}
31+
if (possibleAgain) {
32+
returntrue;
33+
}
34+
}
35+
}
36+
returnfalse;
37+
}
38+
}
39+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
packagecom.fishercoder.fourththousand;
2+
3+
importcom.fishercoder.solutions.fourththousand._3349;
4+
importorg.junit.jupiter.api.BeforeEach;
5+
importorg.junit.jupiter.api.Test;
6+
7+
importjava.util.Arrays;
8+
9+
importstaticorg.junit.jupiter.api.Assertions.assertFalse;
10+
importstaticorg.junit.jupiter.api.Assertions.assertTrue;
11+
12+
publicclass_3349Test {
13+
private_3349.Solution1solution1;
14+
15+
@BeforeEach
16+
publicvoidsetup() {
17+
solution1 =new_3349.Solution1();
18+
}
19+
20+
@Test
21+
publicvoidtest1() {
22+
assertTrue(solution1.hasIncreasingSubarrays(Arrays.asList(2,5,7,8,9,2,3,4,3,1),3));
23+
}
24+
25+
@Test
26+
publicvoidtest2() {
27+
assertFalse(solution1.hasIncreasingSubarrays(Arrays.asList(1,2,3,4,4,4,4,5,6,7),5));
28+
}
29+
30+
@Test
31+
publicvoidtest3() {
32+
assertTrue(solution1.hasIncreasingSubarrays(Arrays.asList(5,8, -2, -1),2));
33+
}
34+
35+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp