Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 87a46e1

Browse files
committed
增加No155
1 parent 0d90fca commit 87a46e1

File tree

4 files changed

+109
-92
lines changed

4 files changed

+109
-92
lines changed

.idea/leetcode.iml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/workspace.xml

Lines changed: 47 additions & 74 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

leetcode/binarysearch/No744.java

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
1-
package Algorithm.leetcode.binarysearch;
21

32
/**
4-
*
53
* Created by tujietg on Nov 6, 2019
64
*/
75
public class No744 {
8-
public char nextGreatestLetter(char[] letters, char target) {
9-
int len = letters.length;
10-
int tarInt = target - 'A' + 1;
11-
int lerInt = letters[len - 1] - 'A' + 1;
12-
if (target == 'z' || tarInt >= lerInt) {
13-
return letters[0];
14-
}
15-
int i;
16-
for (i = 1; i < len; i++) {
17-
int leInt = letters[i - 1] - 'A' + 1;
18-
if (leInt > tarInt) {
19-
break;
20-
}
21-
}
22-
return letters[i - 1];
23-
}
6+
public char nextGreatestLetter(char[] letters, char target) {
7+
int len = letters.length;
8+
int tarInt = target - 'A' + 1;
9+
int lerInt = letters[len - 1] - 'A' + 1;
10+
if (target == 'z' || tarInt >= lerInt) {
11+
return letters[0];
12+
}
13+
int i;
14+
for (i = 1; i < len; i++) {
15+
int leInt = letters[i - 1] - 'A' + 1;
16+
if (leInt > tarInt) {
17+
break;
18+
}
19+
}
20+
return letters[i - 1];
21+
}
2422

2523
}

leetcode/stack/No155.java

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import java.util.LinkedList;
2+
3+
/**
4+
* @author tujietg
5+
* @date 5/13/20 9:48 AM
6+
*/
7+
public class No155 {
8+
9+
LinkedList<Integer> list = null;
10+
LinkedList<Integer> minList = null;
11+
12+
/**
13+
* initialize your data structure here.
14+
*/
15+
public No155() {
16+
list = new LinkedList();
17+
minList = new LinkedList();
18+
19+
}
20+
21+
public void push(int x) {
22+
list.addFirst(x);
23+
if (minList.size() == 0 || minList.element() >= x) {
24+
minList.addFirst(x);
25+
}
26+
}
27+
28+
public void pop() {
29+
if (minList.get(0).equals(list.element())) {
30+
minList.poll();
31+
}
32+
list.poll();
33+
}
34+
35+
public int top() {
36+
return list.element();
37+
38+
}
39+
40+
public int getMin() {
41+
return minList.get(0);
42+
}
43+
44+
45+
}

0 commit comments

Comments
 (0)