fork download
  1. using System;
  2.  
  3. public class Test
  4. {
  5. public static void Main()
  6. {
  7.  
  8. }
  9.  
  10. public int[] FindSumMostAppear(int[] nums){
  11. var f = new Dictionary<int, int>();
  12. int maxAppear = 0;
  13.  
  14. foreach(var num in nums){
  15. if(f.TryGetValue(num, out int count)){
  16. f[num] = count + 1;
  17. }
  18. else{
  19. f.Add(num, 1);
  20. }
  21. }
  22.  
  23. foreach(var e in f){
  24. if(e.Value > maxAppear){
  25. maxAppear = e.Value;
  26. }
  27. }
  28. var sum = new List<int>();
  29. foreach(var e in f){
  30. if(e.Value == maxAppear){
  31. sum.Add(e.Value * e.Key);
  32. }
  33. }
  34.  
  35. return sum.ToArray();
  36. }
  37. }
  38.  
Success #stdin #stdout 0.03s 23712KB
stdin
Standard input is empty
stdout
Standard output is empty