Skip to main content
All Questions

Find the maximum subarray sum.

Medium

Given an array of integers nums, write a function maxSubarraySum to find the maximum sum of a contiguous subarray within the array and return that maximum sum. The subarray must be contiguous, meaning that the elements must appear consecutively in the original array.

Examples

Input: nums = [2, 3, -2, 4] Output: 7 Explanation: Maximum sum is 2 + 3 + (-2) + 4 = 7. Input: nums = [1, -1, -5, -4] Output: 1 Explanation: The maximum sum is 1, which is the single element with the highest value.

Interview experiences

7 shared
Amazon · a month ago
"The difficulty level was medium, interviewer was very interested in understanding the different approaches rather then looking on a particular solution"
Software Engineer · Senior / L5
Opentext · 2 months ago
"Overall, the interview process was smooth and well-structured. The interviewers were friendly and gave me a good opportunity to explain my experience and approach to problem-solving. I felt the conversations were engaging, although a few questions were challenging and required me to think on my feet."
Machine Learning Engineer · Intern
Google · 6 months ago
"Pretty easy, just very long. For technical just need to do leetcode, no system design. Interviewers help you if you are stuck."
Software Engineer · Entry Level / L3
Cognizant · a year ago
"The Process was easy, even though I am in my final year of B.Tech. I would say basics from multiple domains or tech stacks are enough to get into Cognizant for freshers."
Software Engineer · Entry Level / L3
Meta · 2 years ago
"One of the technical rounds was ridiculous, a LC hard (LC3548) ML Systems Design was pretty standard - design a recommender system Behavioral round fairly standard"
Machine Learning Engineer · Senior / L5
Amazon · 2 years ago
"A lot of focus spent in every round on LP questions. Make sure to have sufficient stories, sometimes they plan to ask two, but end up asking a third one."
Software Engineer · Mid Level / L4
Amazon · 2 years ago
"The interview loop was definitely more AI/ML focused than software focused. There was no leetcode really, but I did have to write a simple KNN algorithm from scratch."
Machine Learning Engineer · Senior / L5

Related courses

Course

Machine Learning Engineer Interview Prep

Land your dream machine learning role at Meta, Google, Amazon, Apple, Microsoft, Nvidia, and other top companies. Learn from mock interviews, frameworks, and advice from senior candidates. Explore ML system design, core concepts, coding, behavioral interviews, and more.

Course

Data Science Interview Prep

Land your dream data science role at Google, Amazon, Microsoft, Meta, Apple, and other top companies. Learn from mock interviews, frameworks, and advice from senior candidates. Practice statistics, experimentation, coding, SQL, machine learning, behavioral interviews, and more.