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 | 472 Views, 23307 Search Bots | 80 Words
| Browse | Archive
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 472 Views, 23307 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 | 472 Views, 23307 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: Minimum Removals for Valid Parenthesis
- Compare Version Numbers
- Daily Interview Problem: Get all Values at a Certain Height in a Binary Tree
- Daily Interview Problem: Spiral Traversal of Grid
- Algorithm Interview: Determine If Linked List is Palindrome
- Two-Sum
- Daily Interview Problem: Maximum Profit From Stocks
- Top K Frequent words
- Daily Interview Puzzle: Intersection of Linked Lists
- Plus One
©2006~2024 SteakOverCooked - 0.01019 Seconds(s) - 1914.404 KB/s - 15 Online Memory: 493.82 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 !