We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
https://github.com/liuyubobobo/Play-with-Data-Structures/blob/master/09-Segment-Tree/03-Building-Segment-Tree/src/SegmentTree.java#L20-L26
线段树 build 中的递归终止条件少一个 l > r, 当构造函数传入空数组时会使 l > r 导致无限递归. (虽然应该不会有传入空数组的情况, 但感觉还是要加上这个条件比较好)
build
l > r
private void buildSegmentTree(int treeIndex, int l, int r){ if(l > r) return; if(l == r){ tree[treeIndex] = data[l]; return; }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
https://github.com/liuyubobobo/Play-with-Data-Structures/blob/master/09-Segment-Tree/03-Building-Segment-Tree/src/SegmentTree.java#L20-L26
线段树
build
中的递归终止条件少一个l > r
, 当构造函数传入空数组时会使l > r
导致无限递归. (虽然应该不会有传入空数组的情况, 但感觉还是要加上这个条件比较好)The text was updated successfully, but these errors were encountered: