Java Array Min Value minimumDotProduct(int[] a, int[] b)

Here you can find the source of minimumDotProduct(int[] a, int[] b)

Description

minimum Dot Product

License

Open Source License

Declaration

public static long minimumDotProduct(int[] a, int[] b) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.util.Arrays;

public class Main {
    public static long minimumDotProduct(int[] a, int[] b) {
        Arrays.sort(a);/*from w  w  w .  ja  v  a2  s.  c  o  m*/
        Arrays.sort(b);
        long result = 0;
        for (int i = 0; i < a.length; i++) {
            result += (long) a[i] * b[b.length - i - 1];
        }
        return result;
    }
}

Related

  1. minIgnoreIndex(double[] array, int indexToIgnore)
  2. minimum(char[] set)
  3. minimum(double[] list)
  4. minimum(float[] array)
  5. minimum(int... values)
  6. minimumOf(final int[] array)
  7. minimumWordLength(String[] words)
  8. minIn(double[] array)
  9. minIndex(double values[])