problem303

package
v1.6.3 Latest Latest
Warning

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

Go to latest
Published: May 30, 2020 License: MIT Imports: 0 Imported by: 0

README

< Previous                  Next >

303. Range Sum Query - Immutable (Easy)

Given an integer array nums, find the sum of the elements between indices i and j (ij), 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.

[Dynamic Programming]

Similar Questions

  1. Range Sum Query 2D - Immutable (Medium)
  2. Range Sum Query - Mutable (Medium)
  3. Maximum Size Subarray Sum Equals k (Medium)

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
}

func Constructor

func Constructor(nums []int) NumArray

func (*NumArray) SumRange

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

Jump to

Keyboard shortcuts

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