To the Top
File:  root - text - article - 2019 - 11 - contiguous-subarray-with-maximum-sum.txt
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 158 Views, 15593 Search Bots | 80 Words

Subscribe to Feed Burner | Browse | Archive
Hi, here's your problem today. This problem was recently asked by Twitter:

You are given an array of integers. Find the maximum sum of all possible contiguous subarrays of the array.

Example:

[34, -50, 42, 14, -5, 86]

Given this input array, the output should be 137. The contiguous subarray with the largest sum is [42, 14, -5, 86].

Your solution should run in linear time.

Here's a starting point:


def max_subarray_sum(arr):
# Fill this in.

print max_subarray_sum([34, -50, 42, 14, -5, 86])
# 137
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Cateogry: Computing | 158 Views, 15593 Search Bots | 80 Words Subscribe to Feed Burner

Related Articles

  1. Palindrome Integers
  2. Daily Interview Problem: Word Ordering in a Different Alphabetical Order
  3. Daily Interview Problem: Get all Values at a Certain Height in a Binary Tree
  4. Algorithm Interview Question: Nth Fibonacci Number
  5. Kaprekar
  6. [Daily Problem] Witness of The Tall People
  7. Skip the readings, focus on problems. And use all the hints!
  8. Batch Programming in XP
  9. Daily Interview Problem: Running Median
  10. Daily Interview Problem: Given two arrays, write a function to compute their intersection.

Comments (0)

    Be the first one to comment this page !


Page Edited: October 30 2020 14:21:09 | RSS Subscription
How to Cook a Perfect Steak? | <meta name="robots" content="index, follow">