CHuiL

236. Lowest Common Ancestor of a Binary Tree

leetcode

题目 Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree. According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between two no...

56. Merge Intervals

leetcode

题目 Given a collection of intervals, merge all overlapping intervals. 题意 给定间隔的集合,合并所有重叠的间隔。 例子 Input: [[1,3],[2,6],[8,10],[15,18]] Output: [[1,6],[8,10],[15,18]] Explanation: Since intervals [1,3] ...

200. Number of Islands

leetcode

题目 Given a 2d grid map of ‘1’s (land) and ‘0’s (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may ...

328. Odd Even Linked List

leetcode

题目 Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the value in the nodes. You should try to do i...

279. Perfect Squares

leetcode

题目 Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, …) which sum to n. 描述 给定一个数n,求最少需要多少个完全平方数求和能得到n;完全平方数为1,4,9,16… 例子 Input: n = 13 Output:...

131. Palindrome Partitioning

leetcode

题目 Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s. 题意 给定一个字符串s,分隔该字符串,若分隔后的所有子串都是回文字符串,则输出 例子 Input: “...

go调度器

go学习记录

Go调度器有两大思想 复用线程:协程本身就是允许在一些线程上面的,不需要频繁的创建、销毁线程,而是对线程的复用。在调度器中有两个具体的体现 1)work stealing:当本地线程可运行g队列为空时,尝试从其他线程绑定的P偷取G,而不是销毁线程。 2)hand off:当本地线程因为G进行系统调用阻塞时,线程释放绑定的P,把P转移给其他空闲的线程执行。 利用并行:GOMAXPROCS设置...

46. Permutations

leetcode

题目 Given a collection of distinct integers, return all possible permutations. ### 题意 求数组的全部排列 例子 Input: [1,2,3] Output: [ [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], [3,2,1] ] 题解 求排序...

238. Product of Array Except Self

leetcode

题目 Given an array nums of n integers where n > 1, return an array output such that output[i] is equal to the product of all the elements of nums except nums[i]. 题意 给定具有n个整型的数组,对应输出一个数组,该数组元素为除...

Time_Wait问题总结

Time_Wait 四次挥手的过程中,最先主动发起FIN报文的一端最后会进入TIME_WAIT状态。 Time_Wait存在的目的 允许老的重复分节在网络中消逝,使其不影响后来的连接。假设原本FIN报文发出后在网络中滞留了,重发后顺利断开了连接。过了一段时间后,又建立起了新的连接,用的是相同的端口号,这个时候FIN报文到达就会对当前的连接造成影响 可靠的关闭连接,如果最后发送的AC...