树状数组(Binary Indexed Tree(B.I.T)) 是一个查询和修改复杂度都为log(n)的数据结构。主要用于查询任意两位之间的所有元素之和,但是每次只能修改一个元素的值;经过简单修改可以在log(n)的复杂度下进行范围修改,但是这时只 能查询其中一个元素的值(如果加入多个辅助数组则可 ...
分类:
编程语言 时间:
2018-03-29 00:11:47
阅读次数:
263
LeetCode解题之Recover Binary Search Tree 原题 一棵二叉搜索树中的两个节点交换了位置,找出并调整。 注意点: 最好仅仅用常量的空间 样例: 输入: 3 / \ 1 2 输出: 2 / \ 1 3 解题思路 二叉搜索树的中序遍历能够使它的节点排列成一个递增的序列,那就 ...
分类:
其他好文 时间:
2018-03-28 14:24:31
阅读次数:
142
Description Coco is a beautiful ACMer girl living in a very beautiful mountain. There are many trees and flowers on the mountain, and there are many a ...
分类:
其他好文 时间:
2018-03-28 14:20:36
阅读次数:
148
①二叉树的定义:二叉树是由n(n>=0)个结点组成的有限集合,该集合或者为空,或者是由一个根结点加上两颗分别称为左子树和右子树的、互不相交的二叉树组成 ②二叉树的五种不同形态: ③满二叉树(Full Binary Tree):如果二叉树中的所有分支结点的度数都为二,且叶子结点都在同一层上,则称这类二 ...
分类:
其他好文 时间:
2018-03-28 14:11:56
阅读次数:
208
Given a binary search tree and a node in it, find the in-order successor of that node in the BST. Note: If the given node has no in-order successor in ...
分类:
其他好文 时间:
2018-03-28 10:28:59
阅读次数:
214
【题目描述】 Count how many 1 in binary representation of a 32-bit integer. 计算在一个 32 位的整数的二进制表示中有多少个1. 【题目链接】 www.lintcode.com/en/problem/count-1-in-binary/ ...
分类:
其他好文 时间:
2018-03-28 00:01:06
阅读次数:
201
在一个标准群集场景中,节点通过一个数据包发送到协定好的多播IP地址:Port上,建立起通信。比如使用TCP插头。 1.连接上@ServerEndPoint 【节点】 ...
分类:
Web程序 时间:
2018-03-27 20:57:31
阅读次数:
220
Find the height of binary tree. Examples: 5 / \ 3 8 / \ \ 1 4 11 The height of above binary tree is 3. 1 public class Solution { 2 ... ...
分类:
其他好文 时间:
2018-03-27 14:31:32
阅读次数:
132
DFS recursive: since this is called tail recursion, you are recommended to do it in interative: time: O(n) space: O(1) Interative: ...
分类:
其他好文 时间:
2018-03-27 10:23:32
阅读次数:
179
// this code is not right. needs to be updated ...
分类:
其他好文 时间:
2018-03-27 10:23:17
阅读次数:
134