About 298,000 results
Open links in new tab
  1. Maximum subarray sum in O (n) using prefix sum

    Oct 12, 2022 · Given an integer array arr[] of size N and two integer L and R. The task is to find the maximum sum subarray of size between L and R (both inclusive). Example: Input: arr[] = …

  2. algorithm - Maximum subarray sum modulo M - Stack Overflow

    Jun 29, 2015 · Knowing that subarray[i][j] = (prefix[i] - prefix[j] + m) % m (indicating the modulo sum from index i to j), our maxima when given prefix[i] is always that prefix[j] which is as close …

  3. Maximum Subarray Problem in Java - Baeldung

    Jan 8, 2024 · The maximum subarray problem is a task to find the series of contiguous elements with the maximum sum in any given array. For instance, in the below array, the highlighted …

  4. Mastering Prefix Sum in Java - DEV Community

    Apr 12, 2025 · Convert '0' to -1 and use prefix sum to find longest balanced subarray. public int findMaxLength ( int [] nums ) { Map < Integer , Integer > map = new HashMap <>(); map . put ( …

  5. Maximum Subarray Sum (Kadane's Algorithm) - w3resource

    May 15, 2024 · Walkthrough examples involve step-by-step demonstrations of how to identify the maximum ‘subarray’ sum in a given array using "Kadane's Algorithm". For instance, consider …

  6. Maximum Sum Subarray in Java | AlgoCademy

    In this blog post, we discussed the problem of finding the maximum sum subarray in an array containing both positive and negative integers. We explored a naive approach and an …

  7. Maximum Subarray Sum – Kadane’s Algorithm | GeeksforGeeks

    Feb 28, 2025 · Given an array arr[] of size N. The task is to find the maximum subarray sum possible after performing the given operation at most once. In a single operation, you can …

    Missing:

    • Prefix

    Must include:

  8. java - Find widest subarray with given sum (array slicing

    May 27, 2015 · The idea is, if you have multiple matches for some x1,x2 such that x2-x1 = S, and where x1,x2 are prefix sums, the candidates for longest subarray are the first place where x1 …

  9. Java Program to Find the Maximum Subarray Sum using Naive …

    Here is the source code of the Java program to find maximum subarray sum. The Java program is successfully compiled and run on a Windows system. The program output is also shown …

    Missing:

    • Prefix

    Must include:

  10. Prefix Sum - AlgoMonster

    By computing and storing the prefix sum of an array, you can easily answer queries about the sum of any subarray in constant time. for num in arr: prefix_sum.append(prefix_sum[-1] + …

  11. Some results have been removed