LintCode(12-22)

(12) – Min Stack

一个栈维护最小值,另一个栈存数据

为什么最小值同步插入可行,因为栈的pop只能从栈顶开始,所以:

1.栈顶元素最小,minValue栈顶也是该元素
2.栈顶元素不是最小,minValue中没有该元素

public class MinStack {

    private Stack<Integer> data;
    private Stack<Integer> minValue;

    public MinStack() {
        // do intialization if necessary
        data=new Stack<>();
        minValue=new Stack<>();
        minValue.push(0x3f3f3f3f);
    }

    /*
     * @param number: An integer
     * @return: nothing
     */
    public void push(int number) {
        // write your code here
        data.push(number);
        if(number<=minValue.peek()) minValue.push(number);
    }

    /*
     * @return: An integer
     */
    public int pop() {
        // write your code here
        if(data.peek().equals(minValue.peek())) minValue.pop();
        return data.pop();
    }

    /*
     * @return: An integer
     */
    public int min() {
        // write your code here
        return minValue.peek();
    }
}

Continue reading “LintCode(12-22)”

Spring 注解 @ModelAttribute

Spring MVC 表单标签库

http://www.funtl.com/zh/spring-mvc/Spring-MVC-%E8%A1%A8%E5%8D%95%E6%A0%87%E7%AD%BE%E5%BA%93.html#%E5%8D%95%E9%80%89%E6%8C%89%E9%92%AE%EF%BC%88%E5%A4%9A%E9%80%89%EF%BC%89

JQuery Validation+Bootstrap(前端验证)

http://www.funtl.com/zh/supplement1/jQuery-Validation.html#%E9%A1%B5%E9%9D%A2%E5%BC%95%E7%94%A8

JQuery iCheck+Bootstrap(前端复选框)

http://www.funtl.com/zh/supplement1/jQuery-iCheck.html#%E6%BF%80%E6%B4%BB-icheck

Continue reading “Spring 注解 @ModelAttribute”