node

题237、删除链表中的节点

ε祈祈猫儿з 提交于 2020-01-30 22:23:04
一、题目 1 二、思路 三、代码 public class T0237 { public static void main ( String [ ] args ) { } public void deleteNode ( ListNode node ) { node . val = node . next . val ; node . next = node . next . next ; } } class ListNode { int val ; ListNode next ; ListNode ( int x ) { val = x ; } } 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/delete-node-in-a-linked-list 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。 ↩︎ 来源: CSDN 作者: Le.diablew 链接: https://blog.csdn.net/weixin_45980031/article/details/104117634

binder学习1

喜你入骨 提交于 2020-01-30 20:19:28
Binder机制的引入原因 Binder机制是为C/S架构设计的IPC机制,基于性能和安全性的考虑,Android系统在传统IPC机制之外,又引入了Binder机制。 性能 传统的Socket/管道/消息队列等IPC机制有一个共同点,数据传输过程中,先从发送方的缓冲区copy到内核缓冲区,再从内核缓冲区copy 到接收方缓冲区,数据至少经过两次copy。Binder机制的优化设计,使其仅需要从发送方缓冲区拷贝数据到内核缓冲区,接收方即可直接读取内 核缓冲区中的数据,数据仅需一次copy,提升了数据传输性能。 安全性 Binder机制提供通信方的UID和PID,有助于判断非法访问。并且,Binder机制支持匿名Binder,可以用于规避通过猜测(i.e. 通过猜测 端口地址进行Socket通信)进行通信的风险。 Binder机制的角色 Binder机制包括四个角色:Binder driver、Service Manager、Service、Client. Binder driver Binder driver工作于内核态(kernel space), 作为linux内核的一部分,跟随linux系统启动。它向linux内核注册了MISC设备,就是我们看到的 dev/binder设备文件,当Service/Client调用open/ioctl等系统调用操作dev/binder文件时

线性表--链栈(十一)

半城伤御伤魂 提交于 2020-01-30 19:23:19
写在前面: 大家好,我是 花狗Fdog ,来自内蒙古的一个小城市,目前在泰州读书。 很感谢能有这样一个平台让我能够在这里分享所学所感。 我喜欢编程,喜欢代码,喜欢去做一个程序员。 努力学习,争取多年后,给亲人更好的生活。 QQ / WX:2506897252 欢迎交流。 文章目录 1.介绍链栈 2.代码实现 (1)定义链栈 (2)初始化 (3)进栈 (4)出栈 1.介绍链栈 所谓链栈,就是用链表存储结构实现的栈。采用链栈,可以不事先估计栈的最大容量,只要系统有足够的空间,链栈就不会溢出,在使用完后,应与链表一样,给予相应的内存释放。 2.代码实现 (1)定义链栈 typedef struct node { int data ; struct node * next ; } Node ; (2)初始化 Node * InitStack ( ) { Node * Head = ( Node * ) malloc ( sizeof ( Node ) ) ; Head -> data = 0 ; Head -> next = NULL ; return Head ; } (3)进栈 int Push ( Node * top , int x ) { Node * temp ; temp = ( Node * ) malloc ( sizeof ( Node ) ) ; if ( temp

判断是否是满二叉树

北战南征 提交于 2020-01-30 15:42:05
public static class Node { public int value; public Node left; public Node right; public Node(int data) { this.value = data; } } public static boolean isFull(Node head){ ReturnData allInfo=process(head, 1); return ((1<<allInfo.level)-1==allINfo.nums; } public static class ReturnData{ public int level; public int nums; public ReturnData(int l, int n){ level=l; nums=n; } } public static ReturnData process(Node head, int level){ if(head==null){ return new ReturnData(level, 0); } ReturnData leftInfo = process(head.left, level+1); ReturnData rightInfo = process(head.right, level+1); int nums =

Leetcode之Kth Smallest Element in a BST

怎甘沉沦 提交于 2020-01-30 15:35:59
题目: Given a binary search tree, write a function kthSmallest to find the k th smallest element in it. Note: You may assume k is always valid, 1 ≤ k ≤ BST's total elements. Example 1: Input: root = [3,1,4,null,2], k = 1 3 / \ 1 4 \ 2 Output: 1 Example 2: Input: root = [5,3,6,2,4,null,null,1], k = 3 5 / \ 3 6 / \ 2 4 / 1 Output: 3 Follow up: What if the BST is modified (insert/delete operations) often and you need to find the kth smallest frequently? How would you optimize the kthSmallest routine? 代码: 方法一——迭代法: class Solution { public: int kthSmallest(TreeNode* root, int k) { int cnt = 0; stack

160. 相交链表 golang

試著忘記壹切 提交于 2020-01-30 13:45:06
求两个链表相交 Me func getIntersectionNode(headA, headB *ListNode) *ListNode{ if headA == nil { return headA } if headB == nil { return headB } l1 := headA l2 := headB var a int = 0 node := l1 for node != nil { a += 1 node = node.Next } var b int = 0 node = l2 for node != nil { b += 1 node = node.Next } if a > b { num := a-b for i:=0; i < num; i ++ { l1 = l1.Next } } else if a < b { num := b - a for i := 0; i < num; i++ { l2 = l2.Next } } for l1 != l2 { if l1 == nil { return headB } else { l1 = l1.Next } if l2 == nil { return headA } else { l2 = l2.Next } } return l1; } 来源: CSDN 作者: 寇浩哲 链接: https:/

树与二叉树

戏子无情 提交于 2020-01-30 11:11:20
树 有许多逻辑关系并不是简单的线性关系,在实际场景中,常常存在着一对多,甚至是多对多的情况。其中树和图就是典型的非线性数据结构,我们首先讲一讲树的知识。 什么是树呢?在现实生活中有很多体现树的逻辑的例子。例如你家的“家谱”,就是一个“树”。再如企业里的职级关系,也是一个“树”。 除人与人之间的关系之外,许多抽象的东西也可以成为一个“树”,如一本书的目录。 以上这些例子有什么共同点呢?为什么可以称它们为“树”呢?因为它们都像自然界中的树一样,从同一个“根”衍生出许多“枝干”,再从每一个“枝干”衍生出许多更小的“枝干”,最后衍生出更多的“叶子”。 树(英语:tree)是一种抽象数据类型(ADT)或是实作这种抽象数据类型的数据结构,用来模拟具有树状结构性质的数据集合。它是由n(n>=1)个有限节点组成一个具有层次关系的集合。把它叫做“树”是因为它看起来像一棵倒挂的树,也就是说它是根朝上,而叶朝下的。它具有以下的特点: 每个节点有零个或多个子节点; 没有父节点的节点称为根节点; 每一个非根节点有且只有一个父节点; 除了根节点外,每个子节点可以分为多个不相交的子树; 下面这张图,就是一个标准的树结构。 在上图中,节点1是根节点(root);节点5、6、7、8是树的末端,没有“孩子”,被称为叶子节点(leaf)。图中的虚线部分,是根节点1的其中一个子树。 同时,树的结构从根节点到叶子节点

CentOS7.6部署ceph环境

删除回忆录丶 提交于 2020-01-30 07:50:19
CentOS7.6 部署ceph环境 测试环境: 节点名称 节点IP 磁盘 节点功能 Node-1 10.10.1.10/24 /dev/sdb 监控节点 Node-2 10.10.1.20/24 /dev/sdb OSD节点 Node-3 10.10.1.30/24 /dev/sdb OSD节点 步骤: 主机信息配置 1.1. 修改三台主机的主机名 [root@Node-1 ~]# hostnamectl set-hostname Node-1 [root@Node-2 ~]# hostnamectl set-hostname Node-2 [root@Node-3 ~]# hostnamectl set-hostname Node-3 1.2. 修改三台主机的hosts文件,增加以下记录: [root@Node-1 ~]# vi /etc/hosts 10.10.1.10 Node-1 10.10.1.20 Node-2 10.10.1.30 Node-3 1.3. 关闭三台主机的防火墙和Selinux [root@Node-1 ~]# systemctl stop firewalld.sevice [root@Node-1 ~]# systemctl disable firewalld.sevice [root@Node-1 ~]# vi /etc/sysconfig

node Buffer缓冲区

谁说我不能喝 提交于 2020-01-30 06:28:35
Buffer(缓冲区) Buffer的结构和操作与数组类似,专门用来存储二进制,显示成十六进制,这样显示更短 (1)Buffer数组中一个元素就是一个子节 (2)只要存储的是数字,在存储时是二进制,在页面或控制台通过数组输出元素形式为十进制 将字符串转换成二进制存入Buffer Buffer.from(字符串); Buffer.from(字符串).length; 占内存大小,单位为字节 将Buffer中的二进制转换成字符串 Buffer对象.toString(); 创建指定大小的Buffer var ...=Buffer.alloc(数字); 创建指定子节大小的Buffer,创建后长度不可改变 代码示例: var str = '今晚月色蒙蒙' ; var buf = Buffer . from ( str ) ; console . log ( buf . toString ( ) ) ; console . log ( buf ) ; var buf2 = Buffer . alloc ( 10 ) ; console . log ( buf2 . length ) ; 来源: CSDN 作者: 神奇大叔 链接: https://blog.csdn.net/weixin_43294560/article/details/104105116

11.并发包阻塞队列之LinkedBlockingQueue

最后都变了- 提交于 2020-01-30 04:33:29
jdk1.7.0_79   在上文 《 10. 并发包阻塞队列之 ArrayBlockingQueue 》 中简要解析了 ArrayBlockingQueue 部分源码,在本文中同样要介绍的是 Java 并发包中的阻塞队列 LinkedBlockingQueue 。 ArrayBlockingQueue 队列是由数组实现,而 LinkedBlockingQueue 队列的实现则是链表(单向链表)实现,所以在 LinkedBlockingQueue 有一个 Node 内部类来表示链表的节点。   static final class Node<E> {   E item;//入队元素   Node<E> next;//指向后继节点   Node(E x) {     item = x;   } }   同样它也有 3 个构造方法,与 ArrayBlockingQueue 略有不同。 1 public LinkedBlockingQueue() { 2   this(Integer.MAX_VALUE)//默认构造容量为int型的最大值队列 3 } 4 public LinkedBlockingQueue(int capacity) { 5   if (capacity <= o) throw new IllegalArgumentException(); 6   this