Advertisement
Guest User

Untitled

a guest
Dec 8th, 2019
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.39 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. namespace ConsoleApp1
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             var nums = new []{ 7, 2, 5, 5, 7, 6, 7 };
  11.             var ans = 0;
  12.  
  13.             nums.GroupBy(x => x).Select(x =>
  14.             {
  15.                 ans += x.Key;
  16.                 return x.Key;
  17.             });
  18.  
  19.             Console.WriteLine(ans);
  20.         }
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement