DeepFrontend
Practice ArenaBlogSign in
Go Pro
DeepFrontend

Interview-grade learning paths and hands-on practice for mid-to-senior engineers. Master internals, patterns, and system architecture with runnable code.

All systems operational

Core Courses

  • -JavaScript Internals
  • -React Reconciliation
  • -TypeScript rigor
  • -Next.js Caching
  • -Node.js Event Loop
  • -System Design
  • -Web Security
  • -CSS & Page Layouts

Explore

  • Learning Paths
  • Practice Arena
  • Pricing Options
  • HTML Sitemap

Resources

  • Privacy Policy
  • Terms of Service
  • Email Support

© 2026 DeepFrontend. All rights reserved.

Expert learning environments for web engineering teams.

← All challenges
core15 min

Maximum Subarray (Kadane's Algorithm)

Maximum Subarray

Given an integer array nums, return the largest sum of any contiguous subarray (which must contain at least one element). This is the classic setup for Kadane's algorithm: at each element, either extend the current run or start fresh from here — whichever is larger.

maxSubArray([-2, 1, -3, 4, -1, 2, 1, -5, 4]); // 6  ([4, -1, 2, 1])
maxSubArray([-3, -1, -2]);                     // -1 (all negative — pick the largest)

Run your code to see results.

Stuck? This challenge exercises:

javascript.data-structures