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

Commit45aa87c

Browse files
add 2110
1 parent59e67ad commit45aa87c

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

‎README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ _If you like this project, please leave me a star._ ★
88

99
| # | Title | Solutions | Video | Difficulty | Tag
1010
|-----|----------------|---------------|--------|-------------|-------------
11+
|2110|[Number of Smooth Descent Periods of a Stock](https://leetcode.com/problems/number-of-smooth-descent-periods-of-a-stock/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2110.java)||Medium||
1112
|2109|[Adding Spaces to a String](https://leetcode.com/problems/adding-spaces-to-a-string/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2109.java)||Medium||
1213
|2108|[Find First Palindromic String in the Array](https://leetcode.com/problems/find-first-palindromic-string-in-the-array/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2108.java)||Easy||
1314
|2103|[Rings and Rods](https://leetcode.com/problems/rings-and-rods/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2103.java)||Easy||
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
packagecom.fishercoder.solutions;
2+
3+
publicclass_2110 {
4+
publicstaticclassSolution1 {
5+
publiclonggetDescentPeriods(int[]prices) {
6+
longans =prices.length;
7+
for (inti =0;i <prices.length;i++) {
8+
longstartI =i;
9+
while (i +1 <prices.length &&prices[i] -1 ==prices[i +1]) {
10+
i++;
11+
}
12+
longtotalNum =i -startI +1;
13+
if (totalNum >1) {
14+
ans += ((totalNum -1) *totalNum) /2;
15+
}
16+
}
17+
returnans;
18+
}
19+
}
20+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp