这道题分析函数可以做

[复制链接]
查看11 | 回复8 | 2012-5-21 10:19:41 | 显示全部楼层 |阅读模式
239. Sliding Window Maximum
?
Question Editorial Solution
My Submissions


?Total Accepted: 34731
?Total Submissions: 117980
?Difficulty: Hard

Given an array nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k numbers in the window. Each time the sliding window moves right by one position.
For example,
Given nums = [1,3,-1,-3,5,3,6,7], and k = 3.
Window position
Max
---------------
-----
[13-1] -35367 3
1 [3-1-3] 5367 3
13 [-1-35] 367 5
13-1 [-353] 67 5
13-1-3 [536] 7 6
13-1-35 [367]7

Therefore, return the max sliding window as [3,3,5,5,6,7].
Note:
You may assume k is always valid, ie: 1 ≤ k ≤ input array's size for non-empty array.
回复

使用道具 举报

千问 | 2012-5-21 10:19:41 | 显示全部楼层
SQL> with t as (select 1 n from dual
2
union all
3
select 3from dual
4
union all
5
select -1 from dual
6
union all
7
select -3 from dual
8
union all
9
select 5from dual
10
union all
11
select 3from dual
12
union all
13
select 6from dual
14
union all
15
select 7from dual )
16select n, case when n with t as (select 1 n from dual
2
union all
3
select 3from dual ...
nice
回复

使用道具 举报

千问 | 2012-5-21 10:19:41 | 显示全部楼层
〇〇 发表于 2016-9-7 18:50
nice

天际线那个好难。。。
回复

使用道具 举报

千问 | 2012-5-21 10:19:41 | 显示全部楼层
solomon_007 发表于 2016-9-7 19:28
天际线那个好难。。。

oo请翻译一下,我英语差
回复

使用道具 举报

千问 | 2012-5-21 10:19:41 | 显示全部楼层
solomon_007 发表于 2016-9-7 19:28
天际线那个好难。。。

就是每个x坐标的最高y坐标连起来,
回复

使用道具 举报

千问 | 2012-5-21 10:19:41 | 显示全部楼层
〇〇 发表于 2016-9-7 19:39
就是每个x坐标的最高y坐标连起来,

假设你已经型成了一个B的那样的图形,现在添加一栋新的建筑,那么这个长方形可能与前面的图形产生
很多的交点,这个感觉就不是很好判断。。。
回复

使用道具 举报

千问 | 2012-5-21 10:19:41 | 显示全部楼层
这是欧拉计划吗?又开始折腾了?
回复

使用道具 举报

千问 | 2012-5-21 10:19:41 | 显示全部楼层
这显然不是PE, PE 每这么简单吧,都239了
skyline就是排序,SQL程序员手中没有其它工具,只有排序,只有排序啊


回复

使用道具 举报

千问 | 2012-5-21 10:19:41 | 显示全部楼层
lugionline 发表于 2016-9-8 06:53
这显然不是PE, PE 每这么简单吧,都239了
skyline就是排序,SQL程序员手中没有其它工具,只有排序, ...

是leetcode
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行