pure-jcore/src/main/java/leetcode/FourSum.java
/**
     * all combinations with four indexes in 2d array.
     */
all combinations with four indexes in 2d array.
all combinations with four indexes in 2d array .
public int[][] fourSumsAll(int[] nums, int target) {
        int len = nums.length;
        List<List<int[]>> resultList = new ArrayList<>();
        for (int i = 0; i < len - 2; i++) {
            int four = nums[i];
            int threeSumsTarget = target - four;
            for (int j = i + 1; j < len - 1; j++) {
                int third = nums[j];
                int pairTarget = threeSumsTarget - third;
                List<int[]> listOf4Indexes = fourSums_WithGivenIndexes(nums, pairTarget, j, i);
                if (!listOf4Indexes.isEmpty()) {
                    resultList.add(listOf4Indexes);
                }
            }
        }
        return convertListTo2dArrayWithEachOf4Elements(resultList);
    }
public int [ ] [ ] fourSumsAll ( int [ ] nums , int target ) { int len = nums . length ; List < List < int [ ] > > resultList = new ArrayList < > ( ) ; for ( int i = 0 ; i < len - 2 ; i ++ ) { int four = nums [ i ] ; int threeSumsTarget = target - four ; for ( int j = i + 1 ; j < len - 1 ; j ++ ) { int third = nums [ j ] ; int pairTarget = threeSumsTarget - third ; List < int [ ] > listOf4Indexes = fourSums_WithGivenIndexes ( nums , pairTarget , j , i ) ; if ( ! listOf4Indexes . isEmpty ( ) ) { resultList . add ( listOf4Indexes ) ; } } } return convertListTo2dArrayWithEachOf4Elements ( resultList ) ; }
all combinations with four indexes in 2d array.
all combinations with four indexes in 2d array .