1 Cubic Meter

一立方米

[LeetCode] 3. Longest Substring Without Repeating Characters

发布于 # 解题报告

题目 LeetCode链接 Given a string, find the length of the longest substring without repeating characters. Examples: Given "abcabcbb", the answer is "abc", which the length is 3. Given "bbbbb", the answer is "b", with the length of 1. Given "pwwkew", the answer is "wke", with the length of 3. Note that the answer must be a substring, "pwke" is a subsequenceand not a substring. 解题报告 思路 乍一想可能是动态规划的一道题,实际上

[LeetCode] 2. Add Two Numbers

发布于 # 解题报告

题目 LeetCode链接 You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list. You may assume the two numbers do not contain any leading zero, except the number 0 itself. Example Input: (2 -> 4 -> 3) + (5 -> 6 -> 4) Output: 7 -> 0

[LeetCode] 189. Rotate Array

发布于 # 解题报告

题目 LeetCode链接 Given an array, rotate the array to the right by k steps, where k is non-negative. Example 1: Input: [1,2,3,4,5,6,7] and k = 3 Output: [5,6,7,1,2,3,4] Explanation: rotate 1 steps to the right: [7,1,2,3,4,5,6] rotate 2 steps to the right: [6,7,1,2,3,4,5] rotate 3 steps to the right: [5,6,7,1,2,3,4] Example 2: Input: [-1,-100,3,99] and k = 2 Output: [3,99,-1,-100] Explanation: rotate

为什么公交车来的总比时间表上说的还久?

发布于 # 知识课堂

十字路口的红绿灯,每分钟交替一次的话,你在红灯的时候到达的平均等待时间是多久? $$1/2 = 0.5 $$ 分钟 公交车平均五分钟来一次的话你等公交车要多久? $$5/2 = 2.5$$ 分钟 错啦!这就是经典的等车悖论,因为公交车平均每五分钟来一辆,那么你的平均等待时间将是五分钟。 均匀分布和指数分布 红绿灯和公交车有什么不同的地方呢? 我们往往假设,红绿灯每次交替的时间是固定的(假设是一分钟),是不随着雨天还是晴天而改变的。如果我们在任何时间抵达红绿灯前,我们到达的分布可以视作是均匀分布的(如下图)。 也就是说,在每个红灯的前,我们可能的等待时间是从0分钟(一到灯就绿了)到1分钟之间(一到灯就红了)每个时间出现的可能性是完全一致的。因此我们可以简单地做一个平均运算来算出我们的期待值,也就是说: $$ E[X]=\frac{a+b}{2} = \frac{1+0}{2} = \fr

TLDR pages:简易版的 man pages

发布于 # 软件推荐

什么是TLDR? TLDR 它本身 tl;dr 是一个网络词汇,和十动然拒这类差不多,是个缩写。它的全称是「Too Long; Don't Read」,翻译成中文的话就叫「太长不看」。它兴起于一些论坛,为了说明「楼主你的破文章又臭又长」,不过后来有许多文章的开头也用 这个东西为啥叫太长不看? 一个叫「太长不看」的命令行工具显然是解决一些令程序员一个脑袋两个大的太长的东西,而这个东西就是 Linux man pages。它到底有多长呢,man pages的官方压缩包是 2M 多的大小,解压后是 16M。 16M 确实不算大了,然而这 16M 可是纯文本啊。用来做类比的话,一本50万字的中文小说变成纯文本文件之后也就那么 1M 多,可想而知这甚至是全英文 man pages 有多长了。 我们却需要它 作为程序员有时又十分需要 man pages。 虽然它长,你又不得不去读它:比如说,你知道 s