// the class is made using the book. The solution is orginial.
// 9.6
private class Buildings{
    int id;
    int height;
    public Buildings(int id, int height){
        this.id = id
        this.height = height;
    }
}

/**
 * you are given a buildings with heights. Goal is to return the buildings in a such order that the smallest hegiht is on the west side and the largest
 * is on the east. So that way no building blocks the sunset of other building.
 * input = [ 1, 8, 5]
 * output =[(0,1),(2,5),(1,8)]
 * space is O(n), and time is O(n) time since building is never pushed or popped more than once.
 */
public Stack<Buildings> buildingsView(Iterator<Integer> building) {
    Stack<Buildings> res = new Stack<Buildings>();
    int index = 0;
    while (building.hasNext() ) {
        Integer temp = building.next(); // gives the next element in the iterations will give us the height of the building
        while(res.peek() != null && temp >= res.peek().height()){
            res.pop();
        }
        res.push(new Buildings(index++, temp));
    }
    return res;


}

@@ -1,249 +1,173 @@
 /
-/ the class is made us
+**%0A * Given a list of build
 ing 
-t
 he
- book. The solution is orginial.%0A// 9.6%0Aprivate class Buildings%7B%0A    int id;%0A    int height;%0A    public Buildings(int id, int height)%7B%0A        this.id = id%0A        this.height = height;%0A    %7D%0A%7D%0A%0A/**%0A * you are given
+ights, return a subset of building that can view the westward sun.%0A * All buildings only have windows facing the west.%0A * Therefore, if
  a b
@@ -177,45 +177,24 @@
 ding
-s
  w
-ith heights. Goal is to return 
+est of ano
 the
+r
  bui
@@ -202,442 +202,272 @@
 ding
-s
  i
-n a such order that the smallest hegiht is on the west side and the largest%0A * is on the east. So that way no building blocks the sunset of other building.%0A * input
+s taller, then the second building cannot see the sun.%0A * Ex. %5B1, 2, 3, 4%5D
  =
+%3E
  %5B
- 
 1, 
-8, 5
+2, 3, 4
 %5D%0A * 
-output =%5B(0,1),(2,5),(1,8)%5D%0A * space is O(n), and time is O(n) time since building is never pushed or popped more than once.%0A */%0Apublic Stack%3CBuildings%3E buildingsView(Iterator%3CInteger%3E building) %7B%0A    Stack%3CBuildings
+    %5B4, 3, 2, 1%5D =%3E %5B%5D%0A *     %5B1, 3, 2, 5, 4, 7%5D =%3E %5B1, 3, 5, 7%5D%0A */%0Apublic List%3CInteger%3E buildings(int%5B%5D heights) %7B%0A  List%3CInteger
 %3E res
+ult
  = new 
-Stack%3CBuildings
+ArrayList%3CInteger
 %3E();%0A
-  
   in
@@ -485,44 +485,68 @@
 ;%0A  
-  while (building.hasNext() 
+int currentMax = 0;%0A%0A  while (index %3C heights.length
 ) %7B%0A    
     
@@ -545,283 +545,142 @@
     
-    Integer temp = building.next(); // gives the next element in the iterations will give us the height of the building%0A        while(res.peek() != null && temp %3E= res.peek().height())%7B%0A            res.pop();%0A        %7D%0A        res.push(new Buildings(
+if (heights%5Bindex%5D %3E currentMax) result.add(heights%5Bindex%5D);%0A    currentMax = Math.max(currentMax, heights%5Bindex%5D);%0A    
 index
+ 
 ++
-, temp));%0A  
+;%0A
   %7D%0A
-  
   re
@@ -687,14 +687,15 @@
 turn res
-;%0A%0A
+ult;
 %0A%7D%0A

Fix 9.6