package leetcode;

/**
 * https://leetcode.com/problems/online-stock-span/
 */
public class Problem901 {
    private static class StockSpanner {
        public StockSpanner() {
        }

        public int next(int price) {
            // TODO
            return 0;
        }
    }

    public static void main(String[] args) {
        StockSpanner spanner = new StockSpanner();
        System.out.println(spanner.next(100)); // 1
        System.out.println(spanner.next(80)); // 1
        System.out.println(spanner.next(60)); // 2
        System.out.println(spanner.next(70)); // 1
        System.out.println(spanner.next(60)); // 1
        System.out.println(spanner.next(75)); // 4
        System.out.println(spanner.next(85)); // 6
    }
}

@@ -12,16 +12,41 @@
 tcode;%0A%0A
+import java.util.Stack;%0A%0A
 /**%0A * h
@@ -163,16 +163,77 @@
 anner %7B%0A
+        private final Stack%3CInteger%3E stack = new Stack%3C%3E();%0A%0A
         
@@ -320,15 +320,487 @@
     
-// TODO
+int count = 1;%0A            Stack%3CInteger%3E tmp = new Stack%3C%3E();%0A            tmp.add(price);%0A            while (!stack.isEmpty()) %7B%0A                Integer val = stack.pop();%0A                if (val %3C= price) %7B%0A                    tmp.add(val);%0A                    count++;%0A                %7D else %7B%0A                    tmp.add(val);%0A                    break;%0A                %7D%0A            %7D%0A%0A            while (!tmp.isEmpty()) %7B%0A                stack.add(tmp.pop());%0A            %7D
 %0A   
@@ -815,17 +815,21 @@
  return 
-0
+count
 ;%0A      
@@ -1091,9 +1091,9 @@
  // 
-2
+1
 %0A   
@@ -1130,33 +1130,33 @@
 r.next(70)); // 
-1
+2
 %0A        System.

Update problem 901