lintcode-线段树查询II-247
来源:互联网 发布:超图软件股吧 编辑:程序博客网 时间:2024/06/05 07:16
/* class SegmentTreeNode { * public: * int start, end, count; * SegmentTreeNode *left, *right; * SegmentTreeNode(int start, int end, int count) { * this->start = start; * this->end = end; * this->count = count; * this->left = this->right = NULL; * } * } */class Solution {public: int query(SegmentTreeNode *root, int start, int end) { if(!root||start>end) return 0; if(start<=root->start&&end>=root->end) return root->count; int mid=root->start+(root->end-root->start)/2; if(start>mid) return query(root->right,start,end); else if(end<mid+1) return query(root->left,start,end); else return query(root->left,start,mid)+query(root->right,mid+1,end); }};
0 0
- lintcode-线段树查询II-247
- lintcode(247)线段树查询 II
- 线段树查询 II-LintCode
- LintCode:线段树的查询II
- LintCode:线段树的查询
- 线段树的查询-LintCode
- 线段树查询 II
- 线段树查询 II
- 线段树查询 II
- LintCode:线段树的构造 II
- 线段树的构造 II-LintCode
- lintcode-线段树的查询-202
- 解题报告:线段树查询 II
- [LintCode]Segment Tree Query 线段树的查询
- lintcode segment-tree-query 线段树的查询
- LintCode线段树/扫描线/查询题总结
- lintcode-线段树
- 【线段树II:区间修改+点查询】hdu 4031 Attack
- 9.24
- CGI,fastcgi和php-fpm
- ZOJ 2369 | SGU 217 | Acdream 1234 自适应辛普森积分
- MATLAB:镜像图片
- android中dp(dip) px sp
- lintcode-线段树查询II-247
- 转载老师的一篇文章——java自学之路
- android基础知识
- 专利申请--权利要求书vs说明书
- 分支结构 -- 2015/09/23
- 纯虚函数
- 使用wireshark进行EtherCAT分析实时性~~·
- C++基础复习-----2(const 与static)
- 分治-归并排序1