Span 指这个元素之前连续的小于这个元素的值有多少个
原理:
维护递减栈
这个栈内的元素是递减的序列
新到一个元素x 依次出栈比x小的(也就是这个元素的Span)

这种问题的关键在于 新来的元素如果比前一个元素小 那么答案是1
如果比前一个元素大 ( 那么前一个元素在之后就完全没有用了, 所以可以出栈, 使用现有的元素进行意义的记录 )

相关题目

  1. Unique Letter String
  2. Sum of Subsequence Widths

907
907是求一个双向的Span 但是有一个重复元素的问题,
我们这里只需要 两遍采取不同的等号即可

还有 10e9 + 7 是浮点型的 应该用 10**9 + 7

901. Online Stock Span [短于线性的时间统计单个元素的Span ]的更多相关文章

  1. [LeetCode] Best Time to Buy and Sell Stock with Cooldown 买股票的最佳时间含冷冻期

    Say you have an array for which the ith element is the price of a given stock on day i. Design an al ...

  2. 【LeetCode-面试算法经典-Java实现】【121-Best Time to Buy and Sell Stock(最佳买卖股票的时间)】

    [121-Best Time to Buy and Sell Stock(最佳买卖股票的时间)] [LeetCode-面试算法经典-Java实现][全部题目文件夹索引] 原题 Say you have ...

  3. CSS 让div,span等块级、非快级元素排列在同一行

    让div,span等块级.非快级元素排列在同一行 by:授客 QQ:1033553122 例子:让两个div排列在同一行 给div添加float样式 <!DOCTYPE html> < ...

  4. [LeetCode] 122. Best Time to Buy and Sell Stock II 买卖股票的最佳时间 II

    Say you have an array for which the ith element is the price of a given stock on day i. Design an al ...

  5. [LeetCode] 123. Best Time to Buy and Sell Stock III 买卖股票的最佳时间 III

    Say you have an array for which the ith element is the price of a given stock on day i. Design an al ...

  6. [LeetCode] 188. Best Time to Buy and Sell Stock IV 买卖股票的最佳时间 IV

    Say you have an array for which the ith element is the price of a given stock on day i. Design an al ...

  7. [LeetCode] 901. Online Stock Span 股票价格跨度

    Write a class StockSpanner which collects daily price quotes for some stock, and returns the span of ...

  8. leetcode 901. Online Stock Span

    Write a class StockSpanner which collects daily price quotes for some stock, and returns the span of ...

  9. [LeetCode] 901. Online Stock Span 线上股票跨度

    Write a class StockSpanner which collects daily price quotes for some stock, and returns the span of ...

随机推荐

  1. PAT甲级——A1117 Eddington Number【25】

    British astronomer Eddington liked to ride a bike. It is said that in order to show off his skill, h ...

  2. 2019-8-31-C#-如何给-ValueTuple-返回值添加注释

    title author date CreateTime categories C# 如何给 ValueTuple 返回值添加注释 lindexi 2019-08-31 16:55:58 +0800 ...

  3. Tensorflow入门篇

     参考Tensorflow中文网(http://www.tensorfly.cn/tfdoc/get_started/introduction.html) ,写一个入门. 1.打开pyCharm,新建 ...

  4. MyEclipse使用总结——Maven项目如何启动运行发布到tomcat中[转]

    前面两篇文章: 新建maven框架的web项目 以及 将原有项目改成maven框架 之后,我们已经有了maven的项目 那么 maven项目到底怎么启动呢 如果我们直接在myeclipse中按以前的启 ...

  5. 菜鸟nginx源码剖析数据结构篇(八) 缓冲区链表ngx_chain_t[转]

    菜鸟nginx源码剖析数据结构篇(八) 缓冲区链表 ngx_chain_t Author:Echo Chen(陈斌) Email:chenb19870707@gmail.com Blog:Blog.c ...

  6. Deepin折腾手记之安装常用软件

    1. 创建快捷方式 在创建快捷图标的文件/usr/share/applications/xx.desktop 编辑内容 [Desktop Entry] Name=VNote X-Deepin-Vend ...

  7. Python学习day08-python进阶(2)-内置方法

    Python学习day08-python进阶(2)-内置方法 列表数据类型内置方法 作用 描述多个值,比如爱好 定义方法       xxxxxxxxxx 2         1 hobby_list ...

  8. python collections 模块 之 deque

    class collections.deque(iterable[,maxlen]): 返回 由可迭代对象初始化的 从左向右的 deque 对象. maxlen: deque 的最大长度,一旦长度超出 ...

  9. SQL Server日常积累

    1:      在Sql Server 中增加一列语句:  alter table table_name add column_name [not null] [references ....]  例 ...

  10. 主从复制系列A

    一.主从原理 Replication 线程   Mysql的 Replication 是一个异步的复制过程,从一个 Mysql instace(我们称之为 Master)复制到另一个 Mysql in ...