Skip to content

Commit 5c341aa

Browse files
add 1608
1 parent 97828cf commit 5c341aa

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+
package com.fishercoder.solutions;
2+
3+
import java.util.Arrays;
4+
5+
public class _1608 {
6+
public static class Solution1 {
7+
public int specialArray(int[] nums) {
8+
Arrays.sort(nums);
9+
int max = nums[nums.length - 1];
10+
for (int x = 1; x <= max; x++) {
11+
int found = 0;
12+
int i = nums.length - 1;
13+
while (i >= 0 && nums[i] >= x) {
14+
i--;
15+
found++;
16+
}
17+
if (found == x) {
18+
return x;
19+
}
20+
}
21+
return -1;
22+
}
23+
}
24+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy