一、题目 1、审题 2、分析 给出一个无序的整形数组,求其有序时相邻元素的最大差值为多大。 二、解答 1、思路: 方法一、 桶排序。 ①、首先找出数组中最大元素、最小元素: max 、min; ②、去除 max、min 时数组剩下 N - 2 个元素,取 N - 1 个桶进行存放,则一个桶内存放元素 ...
分类:
其他好文 时间:
2018-10-15 14:47:28
阅读次数:
180
Given a n-ary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest le ...
分类:
其他好文 时间:
2018-10-14 20:53:01
阅读次数:
102
[TOC] 窗口尺寸 === 概述 类型|说明 | Size | 当前窗口实际大小,通过 获取; Client Size | 客户区大小; Best Size | 最合适的大小,用户可以实现 方法,自定义返回最合适的大小; Best Client Size | 最合适的客户区大小,用户可以实现 方法 ...
分类:
其他好文 时间:
2018-10-14 00:27:21
阅读次数:
174
"104. Maximum Depth of Binary Tree Easy" 方法 使用递归 Time complexity : we visit each node exactly once, thus the time complexity is \mathcal{O}(N)O(N), wh ...
分类:
编程语言 时间:
2018-10-13 16:50:35
阅读次数:
228
一、题目 1、审题 2、分析 求一个整数数组中的连续子串的最大乘积。 二、解答 1、思路: ①、遍历数组,采用三个变量进行记录。 maxCurProduct:包含当前下标的数组元素时的最大乘积。 minCurProduct: 包含当前下标的数组元素时的最小乘积。 product: 当前为止的最大乘积 ...
分类:
其他好文 时间:
2018-10-13 12:57:15
阅读次数:
120
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1 ...
分类:
Web程序 时间:
2018-10-12 16:09:48
阅读次数:
441
https://leetcode.com/problems/maximum-depth-of-n-ary-tree/description/ 非常简单的题目,连edge case 都没有。思路就是:最大深度 = 孩子的最大深度 + 1 ...
分类:
其他好文 时间:
2018-10-11 11:35:39
阅读次数:
164
传送门: "RMQ ST算法" RMQ(Range Minimum/Maximum Query)区间范围最值查询问题 题意 求指定区间值最小的元素 思路 其实就是二分法的思路,统计所有长度为2的非负整数次幂的区间。 然后将所求转化到在包含的几个区间之中寻找最小值。 Online AC Code in ...
分类:
编程语言 时间:
2018-10-10 22:05:10
阅读次数:
149
<!DOCTYPE html><html><head> <meta charset="utf-8"> <meta name="renderer" content="webkit"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome= ...
分类:
Web程序 时间:
2018-10-10 22:02:00
阅读次数:
199