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

Commitf104be6

Browse files
Create _881.java (#147)
* Create _881.java* Update _881.javaplease check once* Add files via upload* Delete 1961. Check If String Is a Prefix of Array.java* Add files via upload* 316 has difficulty level: Medium
1 parent9d648a9 commitf104be6

File tree

3 files changed

+46
-1
lines changed

3 files changed

+46
-1
lines changed

‎README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1034,7 +1034,7 @@ _If you like this project, please leave me a star._ ★
10341034
| 319 |[Bulb Switcher](https://leetcode.com/problems/bulb-switcher/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_319.java) | |Medium| Brainteaser
10351035
| 318|[Maximum Product of Word Lengths](https://leetcode.com/problems/maximum-product-of-word-lengths/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_318.java)||Medium|
10361036
| 317|[Shortest Distance from All Buildings](https://leetcode.com/problems/shortest-distance-from-all-buildings/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_317.java)||Hard|
1037-
| 316 |[Remove Duplicate Letters](https://leetcode.com/problems/remove-duplicate-letters/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_316.java) | |Hard| Stack, Recursion, Greedy
1037+
| 316 |[Remove Duplicate Letters](https://leetcode.com/problems/remove-duplicate-letters/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_316.java) | |Medium| Stack, Recursion, Greedy
10381038
| 315 |[Count of Smaller Numbers After Self](https://leetcode.com/problems/count-of-smaller-numbers-after-self/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_315.java) | |Hard| Tree
10391039
| 314 |[Binary Tree Vertical Order Traversal](https://leetcode.com/problems/binary-tree-vertical-order-traversal/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_314.java) | |Medium| HashMap, BFS
10401040
| 313|[Super Ugly Number](https://leetcode.com/problems/super-ugly-number/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_313.java)||Medium|
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
packagecom.fishercoder.solutions;
2+
3+
publicclass_1961{
4+
publicclassSolution1 {
5+
publicbooleanisPrefixString(Strings,String[]words) {
6+
7+
Stringt="";
8+
inti=0;
9+
10+
while(t.length()<s.length() &&i<words.length){
11+
t+=words[i++];
12+
13+
if(t.equals(s))
14+
returntrue;
15+
}
16+
17+
returnfalse;
18+
19+
}
20+
}
21+
}

‎src/main/java/com/fishercoder/solutions/_881.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,28 @@ public int numRescueBoats(int[] people, int limit) {
5757
returnboats;
5858
}
5959
}
60+
61+
publicstaticclassSolution2 {
62+
publicintnumRescueBoats(int[]people,intlimit) {
63+
Arrays.sort(people);
64+
intend =people.length -1;
65+
intstart =0;
66+
intboatcount =0;
67+
while (end >=start) {
68+
if (people[end] ==limit) {
69+
end--;
70+
boatcount++;
71+
}elseif (people[end] +people[start] <=limit) {
72+
start++;
73+
end--;
74+
boatcount++;
75+
}else {
76+
end--;
77+
boatcount++;
78+
}
79+
}
80+
returnboatcount;
81+
}
82+
}
83+
6084
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp