Prefix Sum 2 Finding the maximum occurrence of an element in ranges / Frequency problem
import java.util.ArrayList; public class PrefixSum2 { // Maximum appearing element in given ranges public static int getMaxOccurence( int [] L, int [] R) { int n = L.length; int [] array = new int [ 1000 ]; for ( int i = 0 ; i < n; i++) { array[ L [i]]++; array[ R [i] + 1 ]--; } int max = array[ 0 ]; ...