``package questionsimport _utils.UseCommentAsDocumentationimport utils.shouldBe/** * Given an integer array nums, handle multiple queries of the following type: * Calculate the sum of the elements of nums between indices left and right inclusive where left <= right. * [Source](https://leetcode.com/problems/range-sum-query-immutable/) */@UseCommentAsDocumentationprivate class NumArray(nums: IntArray) {    val sumArray = IntArray(nums.size) { 0 }    val input = nums    init {        var cumulativeSum = 0        nums.forEachIndexed { index, i ->            cumulativeSum += i            sumArray[index] = cumulativeSum        }    }    fun sumRange(left: Int, right: Int): Int {        val leftSum = sumArray[left]        val rightSum = sumArray[right]        return rightSum - leftSum + input[left]    }}fun main() {    run {        val obj = NumArray(intArrayOf(-2, 0, 3, -5, 2, -1))        obj.sumRange(0, 2) shouldBe 1        obj.sumRange(2, 5) shouldBe -1        obj.sumRange(0, 5) shouldBe -3    }}``
{"ft_lang_label":"__label__en","ft_lang_prob":0.51366,"math_prob":0.9956055,"size":1122,"snap":"2022-27-2022-33","text_gpt3_token_len":297,"char_repetition_ratio":0.11717352,"word_repetition_ratio":0.27160493,"special_character_ratio":0.271836,"punctuation_ratio":0.15104167,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.98908556,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2022-08-13T20:30:34Z\",\"WARC-Record-ID\":\"<urn:uuid:6e3d50f9-4709-4231-921c-bddd3127b14b>\",\"Content-Length\":\"87086\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:139fda86-2153-4bbc-9ba7-694307f57924>\",\"WARC-Concurrent-To\":\"<urn:uuid:753fa4c6-f12d-4ab6-9918-9ec70e3a7a6d>\",\"WARC-IP-Address\":\"34.194.149.67\",\"WARC-Target-URI\":\"https://prashantbarahi.com.np/docs/algorithms/contents/range-sum-query\",\"WARC-Payload-Digest\":\"sha1:CHADZEH2GDE3U4XQZHJSLS5UQFOLOESQ\",\"WARC-Block-Digest\":\"sha1:XXAK5TQGKA6AG7FXMUUDVWHM4SAFMSBB\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2022/CC-MAIN-2022-33/CC-MAIN-2022-33_segments_1659882571987.60_warc_CC-MAIN-20220813202507-20220813232507-00476.warc.gz\"}"}