Ad
Code
Diff
  • import java.util.stream.IntStream;
    
    public class Area {
    
      public static long[] workOutArea(long[] values){
        if (values.length % 2 != 0) {
          return null;
        }
        
        return IntStream.range(0, values.length / 2).mapToLong(i -> values[i * 2] * values[i * 2 + 1]).toArray();
      }
    }
    • import java.util.stream.IntStream;
    • public class Area {
    • public static long[] workOutArea(long[] values){
    • if (values.length % 2 != 0) {
    • return null;
    • }
    • return IntStream.range(0, values.length / 2).mapToLong(i -> values[i * 2] * values[i * 2 + 1]).toArray();
    • }
    • }