本章宗旨:1136 1个图 1个类 3个知识点 6个接口 容器 J2SDK 所提供的容器 API 位于 java.util 包内。 容器 API 的类图如下: Collection 接口的子接口分为:Set接口(包含 HashSet类) + List接口(包含LinkedList 类和 ArrayL ...
分类:
其他好文 时间:
2018-01-07 20:14:03
阅读次数:
99
Given a positive integer, check whether it has alternating bits: namely, if two adjacent bits will always have different values. Example 1: Example 2: ...
分类:
其他好文 时间:
2018-01-07 20:10:22
阅读次数:
142
题目链接:http://codeforces.com/problemset/problem/842/C 题目: Ilya is very fond of graphs, especially trees. During his last trip to the forest Ilya found a ...
分类:
其他好文 时间:
2018-01-07 11:34:26
阅读次数:
197
"欢迎fork and star:Nowcoder Repository github" 117. Populating Next Right Pointers in Each Node II 题目 解析 "117. Populating Next Right Pointers in Each No ...
分类:
其他好文 时间:
2018-01-06 20:04:21
阅读次数:
102
二分法查找:在一组有序的数据中进行查找,首先与中间的数先比较,如果查找的数大于中间的数,则要查找的数在前半段,否则在后半段,这样就会排除一半的数据,如此递归进行下去,则会极大的提高查找的速度。下面利用python代码实现二分查找 排序后会返回所查数据在列表中的索引,如果没查找到返回False ...
分类:
编程语言 时间:
2018-01-04 00:21:47
阅读次数:
184
Period of an Infinite Binary Expansion 题目大意:给你一个分数,求这个分数二进制表示下从第几位开始循环,并求出最小循环节长度。 注释:int范围内。 想法:这题说实话,是一道神题!我们思考一下,如何将一个小数换成二进制?连续的乘2,然后取首位。这样的比较简洁的转 ...
分类:
其他好文 时间:
2018-01-03 19:46:38
阅读次数:
154
一致性hash算法解决的核心问题是,当solt数发生变化的时候能够尽量少的移动数据。该算法最早在《Consistent Hashing and Random Trees:Distributed Caching Protocols for Relieving Hot Spots on the Worl ...
分类:
其他好文 时间:
2018-01-03 17:34:46
阅读次数:
165
1. 背景 本文基于MySQL InnoDB源码对InnoDB中非锁定一致性读是如何实现的作一些简单的探究。 2. 基本概念 2.1 隐藏字段 在经典之作《高性能MySQL》的1.4节中提及了MySQL中MVCC的实现,原著中提及了 InnoDB implements MVCC by storing ...
分类:
数据库 时间:
2018-01-03 00:44:22
阅读次数:
222
Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST. According to the definition of LCA on Wikipedia ...
分类:
其他好文 时间:
2018-01-02 21:27:11
阅读次数:
96
题目描述:用先序遍历的方式把二叉树转换成字符串,其中结点用括号分割,具体示例见 "题目链接" 思路: 1. 先序遍历,先把根结点的值转化成字符串,然后递归的把左右子树的值转化成字符串 2. 把1中的根结点和左右子结点的字符串连接起来就是结果,其中需要注意: 如果右子树存在值,左子树无论有没有值,都需 ...
分类:
编程语言 时间:
2018-01-01 19:27:53
阅读次数:
126