problem0303

package
v0.0.0-...-899dd15 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 11, 2020 License: MIT Imports: 0 Imported by: 0

README

303. Range Sum Query - Immutable

题目

Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive.

Example:

Given nums = [-2, 0, 3, -5, 2, -1]

sumRange(0, 2) -> 1
sumRange(2, 5) -> -1
sumRange(0, 5) -> -3

Note:

  1. You may assume that the array does not change.
  2. There are many calls to sumRange function.

解题思路

见程序注释

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NumArray

type NumArray struct {
	// contains filtered or unexported fields
}

NumArray 是切片的和切片

func Constructor

func Constructor(nums []int) NumArray

Constructor 返回 NumArray

func (*NumArray) SumRange

func (na *NumArray) SumRange(i int, j int) int

SumRange (i,j) == sum(nums[i:j+1])

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL