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

Commit0bb02d1

Browse files
add 2043
1 parent4867456 commit0bb02d1

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-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+
|2043|[Simple Bank System](https://leetcode.com/problems/simple-bank-system/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2043.java)||Medium||
1112
|2042|[Check if Numbers Are Ascending in a Sentence](https://leetcode.com/problems/check-if-numbers-are-ascending-in-a-sentence/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2042.java)||Easy||
1213
|2039|[The Time When the Network Becomes Idle](https://leetcode.com/problems/the-time-when-the-network-becomes-idle/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2039.java)||Medium||
1314
|2038|[Remove Colored Pieces if Both Neighbors are the Same Color](https://leetcode.com/problems/remove-colored-pieces-if-both-neighbors-are-the-same-color/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2038.java)||Medium||
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
packagecom.fishercoder.solutions;
2+
3+
importjava.util.ArrayList;
4+
importjava.util.List;
5+
6+
publicclass_2043 {
7+
publicstaticclassSolution1 {
8+
classBank {
9+
10+
List<Long>list;
11+
12+
publicBank(long[]balance) {
13+
list =newArrayList<>();
14+
for (longb :balance) {
15+
list.add(b);
16+
}
17+
}
18+
19+
publicbooleantransfer(intaccount1,intaccount2,longmoney) {
20+
if (account1 -1 >=list.size()) {
21+
returnfalse;
22+
}elseif (list.get(account1 -1) <money) {
23+
returnfalse;
24+
}elseif (account2 -1 >=list.size()) {
25+
returnfalse;
26+
}else {
27+
Longoriginal =list.remove(account1 -1);
28+
list.add(account1 -1,original -money);
29+
Longremove =list.remove(account2 -1);
30+
list.add(account2 -1,remove +money);
31+
returntrue;
32+
}
33+
}
34+
35+
publicbooleandeposit(intaccount,longmoney) {
36+
if (account -1 >=list.size()) {
37+
returnfalse;
38+
}else {
39+
Longoriginal =list.remove(account -1);
40+
list.add(account -1,original +money);
41+
returntrue;
42+
}
43+
}
44+
45+
publicbooleanwithdraw(intaccount,longmoney) {
46+
if (account -1 >=list.size()) {
47+
returnfalse;
48+
}elseif (list.get(account -1) <money) {
49+
returnfalse;
50+
}else {
51+
Longoriginal =list.remove(account -1);
52+
list.add(account -1,original -money);
53+
returntrue;
54+
}
55+
}
56+
}
57+
58+
}
59+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp