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, 22078 Search Bots | 80 Words
| Browse | Archive
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 461 Views, 22078 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, 22078 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
- Absolute Path
- Algorithm Interview: Convert Roman Numerals to Decimal
- Algorithm Interview: Shifted String
- Daily Interview Problem: Contiguous Subarray with Maximum Sum
- Algorithm Interview Question: Symmetric k-ary Tree
- YES!!
- Two Tricks of Delphi
- Daily Interview Problem: Find the k-th Largest Element in a List
- Generate All IP Addresses
- Daily Interview Problem: Merge List Of Number Into Ranges
©2006~2024 SteakOverCooked - 0.01212 Seconds(s) - 1662.284 KB/s - 707 Online Memory: 492.55 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 !