File tree Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Original file line number Diff line number Diff line change 47
47
| 125 | [ Valid Palindrome] ( https://leetcode.com/problems/valid-palindrome ) | Easy | [ ![ Java] ( https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png )] ( https://github.com/anishLearnsToCode/leetcode-algorithms/blob/master/src/ValidPalindrome.java ) |
48
48
| 136 | [ Single Number] ( https://leetcode.com/problems/single-number ) | Easy | [ ![ Java] ( https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png )] ( https://github.com/anishLearnsToCode/leetcode-algorithms/blob/master/src/SingleNumber.java ) |
49
49
| 141 | [ Linked List Cycle] ( https://leetcode.com/problems/linked-list-cycle ) | Easy | [ ![ Java] ( https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png )] ( https://github.com/anishLearnsToCode/leetcode-algorithms/blob/master/src/LinkedListCycle.java ) |
50
- | 155 | [ Min Stack] ( https://leetcode.com/problems/min-stack ) | Easy |
50
+ | 155 | [ Min Stack] ( https://leetcode.com/problems/min-stack ) | Easy |
51
51
| 157 | [ Read N Characters Given Read4] ( https://leetcode.com/problems/read-n-characters-given-read4 ) | Easy |
52
52
| 160 | [ Intersection of Two Linked Lists] ( https://leetcode.com/problems/intersection-of-two-linked-lists ) | Easy |
53
53
| 167 | [ Two Sum II - Input Array is Sorted] ( https://leetcode.com/problems/two-sum-ii-input-array-is-sorted ) | Easy |
Original file line number Diff line number Diff line change
1
+ import java .util .ArrayList ;
2
+ import java .util .List ;
3
+
4
+ public class MinStack {
5
+
6
+ private final List <Integer > numbers = new ArrayList <>();
7
+
8
+ /** initialize your data structure here. */
9
+ public MinStack () {
10
+ }
11
+
12
+ public void push (int x ) {
13
+ numbers .add (x );
14
+ }
15
+
16
+ public void pop () {
17
+ numbers .remove (numbers .size () - 1 );
18
+ }
19
+
20
+ public int top () {
21
+ return numbers .get (numbers .size () - 1 );
22
+ }
23
+
24
+ public int getMin () {
25
+ int min = Integer .MAX_VALUE ;
26
+ for (int element : numbers ) {
27
+ min = Math .min (min , element );
28
+ }
29
+ return min ;
30
+ }
31
+ }
You can’t perform that action at this time.
0 commit comments