Ad
Code
Diff
  • public class Program
    {
      public static int FindSquaresInArray(int[] arr){
        int sum = 0;
    
        foreach(int item in arr)
        {
          sum += item * item;
        }
        
        return sum;
      } 
    }
    • using System.Linq;
    • public class Program
    • {
    • public static int FindSquaresInArray(int[] arr){
    • return arr.Sum(x => x * x);
    • int sum = 0;
    • foreach(int item in arr)
    • {
    • sum += item * item;
    • }
    • return sum;
    • }
    • }