文件名称:java_code
介绍说明--下载内容来自于网络,使用问题请自行百度
构造数组的最大MaxTree
时间复杂度O(N) 额外空间复杂度O(N)(* establish the tree with the following principles:
* 1. the father of each number is the first larger number on its left and the smaller one on its right, the first one larger than it
* 2. if a number is infinite on the left, it's not on the right. That is to say, this number is the maximum in the entire number
* * /
How / / as soon as possible to find out each one on both sides of the first larger number? Using stack
Find / left, from left to right through each number, keep the descending order of the stack, the new data kept by the pop from the top of the stack, the stack until the new number or number ratio
Find / right, from right to left traverse each number, keep the descending order of the stack, the new data kept by the pop from the top of the stack, the stack until the new number or number ratio)
时间复杂度O(N) 额外空间复杂度O(N)(* establish the tree with the following principles:
* 1. the father of each number is the first larger number on its left and the smaller one on its right, the first one larger than it
* 2. if a number is infinite on the left, it's not on the right. That is to say, this number is the maximum in the entire number
* * /
How / / as soon as possible to find out each one on both sides of the first larger number? Using stack
Find / left, from left to right through each number, keep the descending order of the stack, the new data kept by the pop from the top of the stack, the stack until the new number or number ratio
Find / right, from right to left traverse each number, keep the descending order of the stack, the new data kept by the pop from the top of the stack, the stack until the new number or number ratio)
相关搜索: 构建数组的最大MaxTree
(系统自动生成,下载前可以参看下载内容)
下载文件列表
java_code
java_code\MaxTree.java
java_code\MaxTree.java
本网站为编程资源及源代码搜集、介绍的搜索网站,版权归原作者所有! 粤ICP备11031372号
1999-2046 搜珍网 All Rights Reserved.