Ad
Code
Diff
  • import java.util.Arrays;
    
    public class SpeedLimit {
      public static int sequence(int[] arr) {
        return Arrays.stream(arr).sum();
      }
    }
    
    • import java.util.Arrays;
    • public class SpeedLimit {
    • public static int sequence(int[] arr) {
    • int result = 0; // initialize the result to 0
    • for (int i = 0; i < arr.length; i++) {
    • // add the current element to the result
    • result += arr[i];
    • }
    • return result; // return the result
    • }
    • public static int sequence(int[] arr) {
    • return Arrays.stream(arr).sum();
    • }
    • }