Created
July 17, 2018 06:32
-
-
Save mgonzales3/16f9946383dbafd21bee8244f2073fd5 to your computer and use it in GitHub Desktop.
minMax
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void minMax(int[] arr) | |
{ | |
List<int> nbrs = new List<int>(); | |
List<long> result = new List<long>(); | |
foreach (int i in arr) | |
nbrs.Add(i); | |
nbrs.Sort(); | |
for (int i = 0; i < 5; i++) | |
{ | |
result.Add(addNbrs(i, nbrs)); | |
} | |
result.Sort(); | |
Console.WriteLine(result.First()); | |
Console.WriteLine(result.Last()); | |
} | |
static long addNbrs(int index, List<int> nbrs) | |
{ | |
long mret = 0; | |
List<long> newNbrs = new List<long>(); | |
foreach (int i in nbrs) | |
{ | |
newNbrs.Add(i); | |
} | |
newNbrs.RemoveAt(index); | |
mret = newNbrs.Sum(); | |
return mret; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment