FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
leetcode/stack/No155.java at master · Programming-With-Love/leetcode · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
Programming-With-Love
/
leetcode
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
15
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
leetcode
/
stack
/
No155.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
45 lines (34 loc) · 779 Bytes
Breadcrumbs
leetcode
/
stack
/
No155.java
Copy path
File metadata and controls
45 lines (34 loc) · 779 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import
java
.
util
.
LinkedList
;
/**
* @author tujietg
* @date 5/13/20 9:48 AM
*/
public
class
No155
{
LinkedList
<
Integer
>
list
=
null
;
LinkedList
<
Integer
>
minList
=
null
;
/**
* initialize your data structure here.
*/
public
No155
() {
list
=
new
LinkedList
();
minList
=
new
LinkedList
();
}
public
void
push
(
int
x
) {
list
.
addFirst
(
x
);
if
(
minList
.
size
() ==
0
||
minList
.
element
() >=
x
) {
minList
.
addFirst
(
x
);
}
}
public
void
pop
() {
if
(
minList
.
get
(
0
).
equals
(
list
.
element
())) {
minList
.
poll
();
}
list
.
poll
();
}
public
int
top
() {
return
list
.
element
();
}
public
int
getMin
() {
return
minList
.
get
(
0
);
}
}
Back
|
FazBrowse Home
|
New Git URL