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 | 188 Views, 17133 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 | 188 Views, 17133 Search Bots | 80 Words Subscribe to Feed Burner

Related Articles

  1. [Daily Problem] Witness of The Tall People
  2. Sort a Partially Sorted List
  3. Daily Interview Problem:Create a balanced binary search tree
  4. New Vulnerabilities (CVE-2016-4581) have been detected in CentOS/RHEL/CloudLinux 7
  5. Binary Tree Level with Minimum Sum
  6. [Daily Problem] Remove k-th Last Element From Linked List
  7. Daily Interview Question: Longest Sequence with Two Unique Numbers
  8. Daily Interview Problem: Circle of Chained Words
  9. 56 Bytes
  10. Palindrome Integers

Comments (0)

Your Email (Domain Part Not Exposed):

Your Comments:

Privately By Mail Colors More Smileys S x y @

Verification (Click Image 2 Refresh):

    Be the first one to comment this page !


Page Edited: May 11 2024 14:36:49 | RSS Subscription
How to Cook a Perfect Steak? | <meta name="robots" content="noindex, follow" />