GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • rulcode
  • Sign In

This view

  • Original page
  • New address

GeezerVison is showing rulcode.com — Kadane's Algorithm Visualizer & Solution | Rulcode

Fetching algorithms...

    Kadane's Algorithm Visualizer & Solution | Rulcode
    Loading problem details...

    5. Kadane's Algorithm

    Medium
    Topics
    Hint

    Understand Before Coding

    Visualize This Problem
    Open Visualizer
    Draw Your Approach
    Draw

    Example 1:

    Input: nums = [-2,1,-3,4,-1,2,1,-5,4]
    Output: 6
    Explanation: The subarray [4,-1,2,1] has the largest sum = 6.

    Example 2:

    Input: nums = [1]
    Output: 1
    Explanation: The subarray [1] has the largest sum = 1.

    Example 3:

    Input: nums = [5,4,-1,7,8]
    Output: 23
    Explanation: The subarray [5,4,-1,7,8] has the largest sum = 23.

    Example 4:

    Input: nums = [-1,-2]
    Output: -1
    Explanation: The subarray [-1] has the largest sum = -1.

    Example 5:

    Input: nums = [-2, -3, 4, -1, -2, 1, 5, -3]
    Output: 7
    Explanation: The subarray [4, -1, -2, 1, 5] has the largest sum = 7.

    Constraints:

    • •
    • •
    • •

    Time Complexity

    O(n)

    Space Complexity

    O(1)

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.