fork download
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. namespace DailyChallenge313Easy
  5. {
  6. class Program
  7. {
  8. static void Main(string[] args)
  9. {
  10. Console.WriteLine(CheckSubsetSum(new List<int> { 1, 2, 3 }));
  11. Console.WriteLine(CheckSubsetSum(new List<int> { -5, -3, -1, 2, 4, 6 }));
  12. Console.WriteLine(CheckSubsetSum(new List<int> { }));
  13. Console.WriteLine(CheckSubsetSum(new List<int> { -1, 1 }));
  14. Console.WriteLine(CheckSubsetSum(new List<int> { -97364, -71561, -69336, 19675, 71561, 97863 }));
  15. Console.WriteLine(CheckSubsetSum(new List<int> { -53974, -39140, -36561, -23935, -15680, 0 }));
  16. }
  17.  
  18. static bool CheckSubsetSum(List<int> input)
  19. {
  20. if (input.Count == 0) return false;
  21.  
  22. for (int i = 0; i < input.Count; i++)
  23. {
  24. if (input[i] == 0) return true;
  25. if (input.Contains(input[i] * -1)) return true;
  26. }
  27.  
  28. return false;
  29. }
  30. }
  31. }
Success #stdin #stdout 0s 131648KB
stdin
Standard input is empty
stdout
False
False
False
True
True
True