合并两个sort好的数组。例子如下, 既然两个数组都已经排好序,而且nums1的size保证能塞得下两个数组长度之和。思路是从后往前比较谁的元素大,谁就把元素放到nums1里面。这样nums1会被下标从右到左,值从大到小被填满。 时间O(m + n) 空间O(1) ...
分类:
其他好文 时间:
2019-10-23 13:40:19
阅读次数:
54
题目描述: Two players, Stan and Ollie, play, starting with two natural numbers. Stan, the first player, subtracts any positive multiple of the lesser of t ...
分类:
其他好文 时间:
2019-10-22 20:12:40
阅读次数:
106
Stream是对集合的包装,通常和lambda一起使用。 使用lambdas可以支持许多操作,如 map, filter, limit, sorted, count, min, max, sum, collect 等等。 同样,Stream使用懒运算,他们并不会真正地读取所有数据,遇到像getFir ...
LintCode 81. Data Stream Median (Hard)思路: 用一个大根堆保存较小的一半数, 一个小根堆保存较大的一半数. 每次根据num和两个堆顶的数据决定往哪个堆里面放. 放完后进行平衡确保两个堆的size差不超过1. 利用两个堆的size和堆顶值计算median.大根堆可... ...
分类:
其他好文 时间:
2019-10-22 10:30:20
阅读次数:
68
Given two words (beginWord and endWord), and a dictionary's word list, find the length of shortest transformation sequence from beginWord to endWord, ...
分类:
其他好文 时间:
2019-10-21 09:18:22
阅读次数:
80
本文源码:GitHub·点这里||GitEE·点这里一、项目结构1、工程结构2、模块命名shard-common-entity:公共代码块shard-open-inte:开放接口管理shard-eureka-7001:注册中心shard-two-provider-8001:8001基于两台库的服务shard-three-provider-8002:8002基于三台库的服务3、代码依赖结构4、项目启
分类:
数据库 时间:
2019-10-20 21:34:20
阅读次数:
111
[TOC] redis NOSQL 什么是NOSQL ? NoSQL(NoSQL = Not Only SQL),意即“不仅仅是SQL” ? 是一项全新的数据库理念,泛指非关系型的数据库。 NOSQL解决什么问题 主流的NOSQL产品 主流产品 键值(Key Value)存储数据库 redis 主要 ...
分类:
其他好文 时间:
2019-10-20 11:20:21
阅读次数:
75
Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number. The function ...
分类:
其他好文 时间:
2019-10-20 10:38:02
阅读次数:
80
The count-and-say sequence is the sequence of integers with the first five terms as following: 1 is read off as "one 1" or 11.11 is read off as "two 1 ...
分类:
其他好文 时间:
2019-10-19 20:30:16
阅读次数:
105
补码(Two's complement)、反码(Ones' Complement)、原码(Sign Magnitude): 注意,补码和反码中,撇号的位置不同。 术语补码来源于这样一个情况,对于非负数x,我们用2? - x(这里只有一个2)来计算-x的n位表示; 术语反码来源于这样一个属性,我们用[ ...
分类:
其他好文 时间:
2019-10-19 14:42:26
阅读次数:
850