filmov
tv
LeetCode 53: Maximum Subarray | Top Tesla and Palantir Interview Problem

Показать описание
In this episode, we solve Leetcode problem 53, an easy problem where we find the longest contigue set of numbers in an array that add up to the largest sum. We accomplish this using Python 3. Watch and enjoy.
Top Software/ Coding Channels:
Top Python Coding Channels:
Snapchat: @christopheribe
Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum.
Input: nums = [-2,1,-3,4,-1,2,1,-5,4]
Output: 6
Explanation: [4,-1,2,1] has the largest sum = 6.
Input: nums = [1]
Output: 1
Input: nums = [5,4,-1,7,8]
Output: 23
Top Software/ Coding Channels:
Top Python Coding Channels:
Snapchat: @christopheribe
Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum.
Input: nums = [-2,1,-3,4,-1,2,1,-5,4]
Output: 6
Explanation: [4,-1,2,1] has the largest sum = 6.
Input: nums = [1]
Output: 1
Input: nums = [5,4,-1,7,8]
Output: 23