Maximum Subarray
Updated
Problem statement
You are given an integer array nums. Find the non-empty contiguous subarray with the largest sum and return that sum.
Function
maxSubArray(nums: int[]) → intExamples
Example 1
nums = [-2,1,-3,4,-1,2,1,-5,4]return = 6The best contiguous subarray is [4,-1,2,1], whose sum is 6.
Constraints
1 <= nums.length <= 100000-10000 <= nums[i] <= 10000- The answer fits in a signed 32-bit integer.
More Squarepoint Capital interview questions
- Mutable Record Store with Error ResultsONSITE INTERVIEW · Seen Sep 2026
- Product of Array Except SelfONSITE INTERVIEW · Seen Aug 2026
- Estimate Pi with a Finite SeriesONSITE INTERVIEW · Seen Oct 2025
- In-Memory Directory and File OperationsONSITE INTERVIEW · Seen Oct 2025
- Count C++ Constructor and Assignment CallsONSITE INTERVIEW · Seen Jun 2025
- Observe a Lazy GeneratorONSITE INTERVIEW · Seen Feb 2025
- Order Matching on ExecuteONSITE INTERVIEW · Seen Dec 2024
- Accumulate Numeric Value ObjectsONSITE INTERVIEW · Seen Sep 2024
- Differentiate a PolynomialONSITE INTERVIEW · Seen Aug 2023
- Lazy Filter over a GeneratorPHONE SCREEN · Seen Nov 2026
Similar questions at other companies
- Best Time to Buy and Sell StockAmazon · ONSITE INTERVIEW
- Best Time to Buy and Sell StockKotak Mahindra Bank · ONSITE INTERVIEWKotak Mahindra Bank interview questions
- Best Time to Buy and Sell StockOracle · PHONE SCREEN · ONSITE INTERVIEWOracle interview questions
- Maximum SubarrayMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
- Best Time to Buy and Sell StockZoox · ONSITE INTERVIEW
- Maximum Subarray SumSafe Security · ONSITE INTERVIEW
- Pascal's TriangleEricsson · ONSITE INTERVIEWEricsson interview questions
- Best Time to Buy and Sell StockMotive · ONSITE INTERVIEWMotive interview questions
- Best Time to Buy and Sell StockBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
- Maximum Profit with Repeated Stock TradesPalantir · ONSITE INTERVIEWPalantir interview questions