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 | 461 Views, 22024 Search Bots | 80 Words
| Browse | Archive
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 461 Views, 22024 Search Bots | 80 Words
| 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:
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Cateogry: Computing | 461 Views, 22024 Search Bots | 80 Words 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
Related Articles
- Daily Interview Problem: Min Stack
- Progess made
- PHP Unit Tests on VPS Server
- Longest Substring Without Repeating Characters
- Daily Interview Question: Longest Sequence with Two Unique Numbers
- Daily Interview Problem: Largest Product of 3 Elements I
- Daily Interview Problem: Arithmetic Binary Tree
- [Daily Problem] Angles of a Clock
- ImageMagick Vulnerabilities - CVE-2016–3714
- Daily Interview Problem: Reverse Words in a String
©2006~2024 SteakOverCooked - 0.00875 Seconds(s) - 6147.545 KB/s - 49 Online Memory: 528.27 KB
18:54:01 up 13 days, 18:33, 2 users, load average: 0.98, 0.86, 0.73 - Server PHP Version: 7.4.33
How to Cook a Perfect Steak? | <meta name="robots" content="noindex, follow" />
18:54:01 up 13 days, 18:33, 2 users, load average: 0.98, 0.86, 0.73 - Server PHP Version: 7.4.33
Comments (0)
Read & Write - Normal - Mini - Post - All Comments - Statistics
Be the first one to comment this page !