The test case [2147483647,-2147483648] should be added for the solution using segment tree. The tree size could be really large if not optimized properly.
If this test case is not expected to pass, then we need to update the description to limit the input numbers in a given range.
Some methods of building a segment tree require the time/space proportional to the max gap of the input, i.e., a method signature like build(left, right). This test case can knock them down.
When using segment tree based on number ranges, the tree size could be really large, and the solution will not be able to find out the result in limited time and memory.
If solution is optimized by using number discretization, then this test case could easily pass.
FYI - if you click "Run code" with this test case, you will see that the solution provided in the "test runner" cannot find out the result for this test case.
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.