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

Commit5c341aa

Browse files
add 1608
1 parent97828cf commit5c341aa

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-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+
|1608|[Special Array With X Elements Greater Than or Equal X](https://leetcode.com/problems/special-array-with-x-elements-greater-than-or-equal-x/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1608.java)||Easy|Array|
1112
|1604|[Alert Using Same Key-Card Three or More Times in a One Hour Period](https://leetcode.com/problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1604.java)||Medium|String, Ordered Map|
1213
|1603|[Design Parking System](https://leetcode.com/problems/design-parking-system/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1603.java)||Easy|Design|
1314
|1601|[Maximum Number of Achievable Transfer Requests](https://leetcode.com/problems/maximum-number-of-achievable-transfer-requests/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1601.java)||Hard|Backtracking|
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
packagecom.fishercoder.solutions;
2+
3+
importjava.util.Arrays;
4+
5+
publicclass_1608 {
6+
publicstaticclassSolution1 {
7+
publicintspecialArray(int[]nums) {
8+
Arrays.sort(nums);
9+
intmax =nums[nums.length -1];
10+
for (intx =1;x <=max;x++) {
11+
intfound =0;
12+
inti =nums.length -1;
13+
while (i >=0 &&nums[i] >=x) {
14+
i--;
15+
found++;
16+
}
17+
if (found ==x) {
18+
returnx;
19+
}
20+
}
21+
return -1;
22+
}
23+
}
24+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp