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

Commit873165c

Browse files
add 3254
1 parent29f7c04 commit873165c

File tree

2 files changed

+31
-0
lines changed
  • paginated_contents/algorithms/4th_thousand
  • src/main/java/com/fishercoder/solutions/fourththousand

2 files changed

+31
-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+
| 3254|[Find the Power of K-Size Subarrays I](https://leetcode.com/problems/find-the-power-of-k-size-subarrays-i/)|[Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3254.java)|| Easy|
34
| 3249|[Count the Number of Good Nodes](https://leetcode.com/problems/count-the-number-of-good-nodes/)|[Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3249.java)|| Medium|
45
| 3248|[Snake in Matrix](https://leetcode.com/problems/snake-in-matrix/)|[Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3248.java)|| Easy|
56
| 3243|[Shortest Distance After Road Addition Queries I](https://leetcode.com/problems/shortest-distance-after-road-addition-queries-i/)|[Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3243.java)|| Medium|
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
packagecom.fishercoder.solutions.fourththousand;
2+
3+
importjava.util.Arrays;
4+
5+
publicclass_3254 {
6+
publicstaticclassSolution1 {
7+
publicint[]resultsArray(int[]nums,intk) {
8+
intn =nums.length;
9+
int[]ans =newint[n -k +1];
10+
booleansorted;
11+
if (k ==1) {
12+
returnnums;
13+
}
14+
Arrays.fill(ans, -1);
15+
for (inti =0;i <=n -k;i++) {
16+
sorted =true;
17+
for (intj =i +1;j <i +k;j++) {
18+
if (nums[j] !=nums[j -1] +1) {
19+
sorted =false;
20+
break;
21+
}
22+
}
23+
if (sorted) {
24+
ans[i] =nums[i +k -1];
25+
}
26+
}
27+
returnans;
28+
}
29+
}
30+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp