(int[] nums)
| 16 | int n; |
| 17 | |
| 18 | public NumArray(int[] nums) { |
| 19 | if (nums.length > 0) { |
| 20 | n = nums.length; |
| 21 | tree = new int[n * 2]; |
| 22 | buildTree(nums); |
| 23 | } |
| 24 | } |
| 25 | |
| 26 | // build the segment tree and store it in array of size 2 * nums[] length |
| 27 | // so the nums[] values are stores at leaves of the segment tree. |