1、给定一个数组和滑动窗口的大小,找出所有滑动窗口里数值的最大值。例如,如果输入数组{2,3,4,2,6,2,5,1}及滑动窗口的大小3,那么一共存在6个滑动窗口,他们的最大值分别为{4,4,6,6,6,5}; 针对数组{2,3,4,2,6,2,5,1}的滑动窗口有以下6个: {[2,3,4],2,6,2,5,1}, {2,[3,4,2],6,2,5,1}, {2,3,[4,2,6],2,5,1}, {2,3,4,[2,6,2],5,1}, {2,3,4,2,[6,2,5],1}, {2,3,4,2,6,[2,5,1]}。

import java.util.ArrayList;
import java.util.Collections;


public class Solution {
    public ArrayList<Integer> maxInWindows(int [] num, int size)
    {
        if(num==null||size<0){
            return null;
        }
        ArrayList<Integer> list=new ArrayList<Integer>();
        if(size==0){
            return list;
        }
        ArrayList<Integer> temp=null;
        int length=num.length;
        if(length<size){
            return list;
        }else{
            for(int i=0;i<length-size+1;i++){
                temp=new ArrayList<Integer>();
                for(int j=i;j<size+i;j++){
                    temp.add(num[j]);
                }
                Collections.sort(temp);
                list.add(temp.get(temp.size()-1));
            }
        }
        return list;
    }
}

2、给一个链表,若其中包含环,请找出该链表的环的入口结点,否则,输出null。

public ListNode EntryNodeOfLoop(ListNode pHead)

    {

         if(pHead==null||pHead.next==null)return null;

         ListNode p1=pHead;

         ListNode p2=pHead;

        while(p2!=null&&p2.next!=null)

         {

            p1=p1.next;

            p2=p2.next.next;

            if(p1==p2)

            {

                p1=pHead;

                while(p1!=p2)

                {

                    p1=p1.next;

                    p2=p2.next;

                }

                if(p1==p2)return p1;

            }

        }

        return null;

    }