Giter Site home page Giter Site logo

postgrad-challenge-largest-subarray-sum-onl01-seng-pt-081720's Introduction

Largest Subarray Sum

Problem

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

Take a look at an example:

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

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

largestSubarraySum(array)
// 16

The largest subarray in this example is [5, 3, -7, 4, 5, 6], and its sum is 5 + 3 - 7 + 4 + 5 + 6 = 16

Process

Run yarn install or npm install to get started.

Write your largestSubarraySum function in index.js.

You can test your solution by running yarn test or npm run test (depending on whether you have yarn or npm installed).

This problem is hard, but it has many different solutions.

Use it as a mechanism to focus on process. Think about this problem as a practice in breaking down problems, and knowing when to retreat from a potential solution. Remember.

A couple of leading questions that might help you get started:

  • What are some examples of input arrays where the solution becomes obvious? What can you learn from those obvious cases?
  • What would a naive solution look like, that tested every possible combination?

Challenge - Time Complexity

After you've implemented a basic solution, consider how many operations it will use to find an answer, based on the size of the input array. If you can, write down the Big O time complexity of your solution.

How could you make your solution faster? Try to improve your solution's runtime, or explain why you think your solution is as fast as possible.

postgrad-challenge-largest-subarray-sum-onl01-seng-pt-081720's People

Contributors

maxwellbenton avatar rrcobb avatar

Watchers

Mar avatar Kaitlin Vignali avatar Mohawk Greene avatar  avatar Joe Cardarelli avatar The Learn Team avatar  avatar Liz Burton avatar Matt avatar Alex Griffith avatar  avatar Amanda D'Avria avatar  avatar Ahmed avatar Nicole Kroese  avatar Dominique De León avatar  avatar Vicki Aubin avatar  avatar  avatar Blake Long 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.