• leetcode-剑指33-OK


    // language c
    // 剑指33
    // https://leetcode-cn.com/problems/er-cha-sou-suo-shu-de-hou-xu-bian-li-xu-lie-lcof/
    
    
    bool verifyPostorder(int* postorder, int postorderSize){
        if(postorderSize==0)
        return true;
    	bool inside(int * NeedToBeJudged, int start, int end){
    		if(start==end)
    			return true;
    		int mid = NeedToBeJudged[end];
    		int p = start;
    		while(NeedToBeJudged[p]<mid)	// 循环完后p指向第一个大于等于mid的值
    			p++;
    		bool left =true;
    		for(int i =p;i<end;i++){
    			if(NeedToBeJudged[i]<=mid){
    				return false;
    			}
    		}
    		bool right = true;
    		if(p>start)
    			left = inside(NeedToBeJudged,start,p-1);
    		if(p<end)
    			right = inside(NeedToBeJudged,p,end-1);
    		return left&&right;
    	}
    
    	return inside(postorder,0,postorderSize-1);
    }
    
  • 相关阅读:
    Python shutil模块
    Flask 上传文件
    Flask DBUtils
    flash-session
    Flash 上下文管理
    python 栈
    python 偏函数
    threding.local
    next() 与 nextLine() 区别
    Thread.sleep(1000*3); // 休眠3秒
  • 原文地址:https://www.cnblogs.com/gallien/p/14353579.html
Copyright © 2020-2023  润新知