线段树
Java 手打线段树,不是通用模板,后续写成模板吧。
Java 手打线段树,不是通用模板,后续写成模板吧。
5个海盗分100个金币,如何分配?
A group of people with assorted eye colors live on an island. They are all perfect logicians -- if a conclusion can be logically deduced, they will do it instantly. No one knows the color of their eyes. Every night at midnight, a ferry stops at the island. Any islanders who have figured out the color of their own eyes then leave the island, and the rest stay. Everyone can see everyone else at all times and keeps a count of the number of people they see with each eye color (excluding themselves), but they cannot otherwise communicate. Everyone on the island knows all the rules in this paragraph. blue eyes
Quick Sort wikipedia 上的实现
Java api mergesort 实现: 长度低于7,利用插入排序替代。
二分查适用于单调区间, 三分查找则要求区间内为凸函数,即只有一个极值,三分查找用于查找极值。
并查集算法
简单实现了Quick-Union的并查集(增加了path compression)。还有Quick-Find, Weighted Quick-union, Weighted Quick-union With Path Compression. 参考https://blog.csdn.net/dm_vincent/article/details/7655764
最短路径算法
利用java实现简单的KMP算法