Giter Site home page Giter Site logo

largest-subarray-sum-dumbo-web-120919's Introduction

Largest Subarray Sum

Problem

Given an array of integers find a sequence with the largest sum.

For example, take a look at an example below.

let array = [1, -1, 5, 3, -7, 4, 5, 6, -100, 4]

function largestSubarraySum(array){
 // code to write here
}

largestSubarraySum(array)
// 16

Process

Mainly, this is your chance to shine. This problem is hard, but one of the nice things about it is that it has many different solutions.

Use it as a mechanism to focus on process, and work with a partner, if you can. Think about this problem as a practice in breaking down problems, and knowing when to retreat from a potential solution. Remember from the last lesson to try to derive what was good and what did not work in your previous attempt, before moving onto a new attempt.

A couple small hints to get started: where are some examples where the solution becomes obvious. What can you learn from it. Ok that's enough.

Be self-aware about when your process. When is your process good, and when it is less successful? We are trying to be disciplined about developing good habits as much as anything else.

A couple more hints for those who have first struggled

If you have not yet worked on this problem yet, and by that we mean spending over an hour with it, then it's time to put away the readme and get to work.

You can come back to this later, but we won't help too much. Still you can find a main hint below.

The main hint is that this is a type of greedy algorithm. It's a new type of algorithm that we did not get a chance to explore. All a greedy algorithm means, is that even before processing all possible information, you can begin to make decisions. Your goal is to try not to regret making the decision at a later time.

So, here a way to apply a greedy approach is to try to determine if a sequence is a potential maximum contiguous subarray even before reading through the entire array. Another mechanism is to think about when one can immediately dispose of a sequence as being a potential sequence, even before reading through the entire array.

With that, get to work.

largest-subarray-sum-dumbo-web-120919's People

Contributors

annjohn avatar pletcher avatar jeffkatzy avatar victhevenot avatar maxwellbenton avatar bhollan avatar rrcobb avatar zacscodingclub avatar graciemcguire avatar 7kingdavid7 avatar jasonpaulso avatar alpha-convert avatar smulligan85 avatar jakebrady5 avatar jeffpwang avatar jonbf avatar tejbans avatar

Watchers

James Cloos avatar Kaitlin Vignali avatar Mohawk Greene avatar  avatar Bernard Mordan avatar Otha avatar raza jafri avatar  avatar Joe Cardarelli avatar The Learn Team avatar  avatar Ben Oren avatar Matt avatar Antoin avatar Alex Griffith avatar  avatar Amanda D'Avria avatar  avatar Ahmed avatar Nicole Kroese  avatar Dominique De León avatar  avatar Lisa Jiang avatar Vicki Aubin avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.