You are viewing a single comment's thread. Return to all comments →
My solution using C# (without if condition)
public static void plusMinus(List<int> arr) { var baseLoop = 0; var answers = new Dictionary<string, int>(); answers.Add("-1", 0); answers.Add("1", 0); answers.Add("0", 0); while (baseLoop < arr.Count) { var checkItem = Math.Sign(arr[baseLoop]); answers[checkItem.ToString()]++; baseLoop++; } System.Console.WriteLine((decimal)answers["1"] / arr.Count + 0.000000m); System.Console.WriteLine((decimal)answers["-1"] / arr.Count + 0.000000m); System.Console.WriteLine((decimal)answers["0"] / arr.Count + 0.000000m); }
Seems like cookies are disabled on this browser, please enable them to open this website
Plus Minus
You are viewing a single comment's thread. Return to all comments →
My solution using C# (without if condition)