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. mavlink 笔记1

    Packet Anatomy This is the anatomy of one packet. It is inspired by the CAN and SAE AS-4 standards. ...

  2. [kuangbin带你飞]专题一 简单搜索 - B - Dungeon Master

    #include<iostream> #include<cstdio> #include<string> #include<vector> #inclu ...

  3. docker 可持续集成及日志管理及监控报警

  4. python安装requests第三方模块

    2018-08-28 22:04:51 1 .下载到桌面后解压,放到python的目录下 ------------------------------------------------------- ...

  5. 最近开始学习python,学习到了关于web的内容。

    然而在win10中IIS发布CGI脚本的时候遇到了各种各样的问题. 如ISAPI和CGI限制,权限限制等等,一一的百度解决了,最后又出现了 HTTP 错误 502.2 - Bad Gateway Th ...

  6. jmeter-测试https请求

    找了一个HTTPS请求的网站尝试. 我用的是chrome,点这个小锁(如果是IE也可以在网页上右键,属性,高级,证书) 或 看到下图,点击“复制到文件” 或 把导出的证书打成.store 用此命令进行 ...

  7. 使用vue-cli搭建vue项目简单教程

    一直没有时间来写些东西,今天就写写vue脚手架吧,初建一个vue项目. vue是近段时间来特别火的一个mvvm框架,小巧.简单.易学,如果你的前端基础还好的话,学起来挺简单的.官网地址: https: ...

  8. vue qs插件的使用

    参考:https://blog.csdn.net/weixin_43851769/article/details/86505164 qs 是一个增加了一些安全性的查询字符串解析和序列化字符串的库. 步 ...

  9. GridView编辑删除

    A前台代码 <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="test.asp ...

  10. leetcode-213-打家劫舍二

    题目描述: 方法一: class Solution(object): def rob(self, nums): """ :type nums: List[int] :rt ...