# 操作系统作用

Consideration make three pointers , pre,current,next; initial pre as null use tmp to save current’s next node info change current’s next to link pre node(first is null) move pre pointer to next node move current pointer to next node soultion 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 /** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { val = x; } * } */ class Solution { public ListNode reverseList(ListNode head) { ListNode pre = null; ListNode current = head; while (current != null){ ListNode next = current.next; current.next = pre; pre = current; current = next; } return pre; } }……

# hamming-distance

The Hamming distance between two integers is the number of positions at which the corresponding bits are different. Given two integers x and y, calculate the Hamming distance. Note: 0 ≤ x, y < 231. Example: Input: x = 1, y = 4 Output: 2 Explanation: 1 (0 0 0 1) 4 (0 1 0 0) ↑ ↑ The above arrows point to positions where the corresponding bits are different. Consideration This problem is also have a relationship with ‘^’ , Think about it : 1(0001) and 4(0100) their Xor is 5(0101) . next we use & Operator to calculate the number of 1 , let the binary & 1 ,if result is 1 ,sum’s up , use » to move the postion. 5(0101) 0&1 = 0 pass 01&01 = 1 sum 010&001 = 0 pass 0101&0001 = 1 sum……

# elasticsearch 集群容错

Q:有三台服务器，三个 Primary Shard怎么配置能使 ElasticSearch 达到高可用 在此之前应该先清楚 shard 、primary shard 、replica shard、node 的概念 还有 primary shard 在确定好个数后后期是无法更改的，能扩容的只有 replica shard。 三个 Primary Shard 的意思就是： 3 primary + 3 replica = 6 shard (默认情况下) 此时服务器的 node 分配如下： 一……

# ElasticSearch 基础概念

documnet 文档，类似于 Java 的实体类，但非面向对象的，比实体类更加灵活。 index 索引，用来存放文档，一个索引可存放若干个 document type ElastcSearch 7 以后过时，使用 _doc 代替，预计在未来会移除 node 单个服务器，其实就是一个 ES 实例，多个 node 组成一个集群，node 能够进行索引和查询操作。默认每个 node 启动时会分配一个 UUID 作为标识。 shard 分片，……