Skip to content

Commit 5475768

Browse files
refactor 218
1 parent 0430ec7 commit 5475768

File tree

1 file changed

+3
-3
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+3
-3
lines changed

src/main/java/com/fishercoder/solutions/_218.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public int compareTo(BuildingPoint o) {
3838
}
3939
}
4040

41-
public List<int[]> getSkyline(int[][] buildings) {
41+
public List<List<Integer>> getSkyline(int[][] buildings) {
4242
BuildingPoint[] bps = new BuildingPoint[buildings.length * 2];
4343
int index = 0;
4444
for (int[] building : buildings) {
@@ -51,7 +51,7 @@ public List<int[]> getSkyline(int[][] buildings) {
5151
//this is one key step:
5252
Arrays.sort(bps);
5353

54-
List<int[]> result = new ArrayList();
54+
List<List<Integer>> result = new ArrayList();
5555
TreeMap<Integer, Integer> treeMap = new TreeMap();
5656
treeMap.put(0, 1);
5757
int prevMaxH = 0;
@@ -74,7 +74,7 @@ public List<int[]> getSkyline(int[][] buildings) {
7474

7575
int currMaxH = treeMap.lastKey();
7676
if (currMaxH != prevMaxH) {
77-
result.add(new int[]{bp.x, currMaxH});
77+
result.add(Arrays.asList(bp.x, currMaxH));
7878
prevMaxH = currMaxH;
7979
}
8080

0 commit comments

Comments
 (0)