Prefix Sums and How They Can be Used to Solve Coding Problemsby@micogongob
1,482 reads

Prefix Sums and How They Can be Used to Solve Coding Problems

tldt arrow
Read on Terminal Reader
Read this story w/o Javascript

Too Long; Didn't Read

Prefix sums is a simple yet powerful technique that we can use to easily calculate the sum of a segment or an array. It allows us to use a reusable lookup array to look up the sum for the whole array in constant time. The first approach would have been how many times we need to recalculate different array segments. With prefix sums, our time is reduced to O(O(n + m) times we can get the sum in constant O(1) time. In this post, we will look at prefix sums and how they can be used to solve a common coding problem.

Company Mentioned

Mention Thumbnail
featured image - Prefix Sums and How They Can be Used to Solve Coding Problems
Mico Gongob HackerNoon profile picture

@micogongob

Mico Gongob


Receive Stories from @micogongob

react to story with heart

RELATED STORIES

L O A D I N G
. . . comments & more!