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
class NumberRemoval | |
{ | |
public static int RemoveAllNumberOccurrence(int[] array, int numberToRemove) | |
{ | |
if (array.Length == 0) | |
{ | |
return 0; | |
} | |
List<int> newNum = new List<int>(); |
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
class DuplicateRemoval | |
{ | |
public static int RemoveDuplicate(int[] numbers) | |
{ | |
if (numbers.Length == 0) | |
{ | |
return 0; | |
} | |
List<int> newArr = new List<int>(); |
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
public static string GetNumberStartAndEnd(int[] numbers, int number) | |
{ | |
if (numbers.Length == 0) | |
{ | |
return "[-1, -1]"; | |
} | |
//If array has a length of 1, it is already sorted so skip | |
if (numbers.Length != 1) | |
{ |
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
class ElementProducts | |
{ | |
//This algorithm works in a way that, i try to find the products of a given array from the left edge up to index i example {1, arr[0], arr[0]*arr[1], | |
//arr[1]*arr[2]*arr[3] } | |
//Then i try to find the products of the given array from the right edge up to index i example {arr[1]*arr[2]*arr[3], arr[2]*arr[3], arr[3], 1} | |
//Then i take the two resulting edges left and right and multiply their element at corresponding position against each other example "products[] = | |
//left[0] * right[0]" and it goes on like that until i reach the final index | |
public static int[] FindElementProduct(int[] array) | |
{ | |
if (array?.Length == null) |
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
class TwoClasses | |
{ | |
public static List<int> MergeClasses(List<int> classA, List<int> classB) | |
{ | |
List<int> mergedClass = new List<int>(classA.Count + classB.Count); | |
//Checks if both classes are empty, throws an exception if true | |
if (classA == null && classB == null || classA.Count == 0 && classB.Count == 0) | |
{ | |
throw new ArgumentNullException("Both classes are empty"); |
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
class ShuffleClass | |
{ | |
public static LinkedList<int> ShuffleAssemblyLine(LinkedList<int> assemblyLine, int shuffleNumber) | |
{ | |
//Checks if the Assembly line is empty, if it is throw an exception | |
if (assemblyLine.Count == 0 || assemblyLine == null) | |
{ | |
throw new ArgumentNullException("Can not shuffle empty class"); | |
} |
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
//You put this configuration code in your Startup.cs or Program.cs file | |
builder.Services.AddHttpClient(); | |
//Example usage | |
using System; | |
using System.Net.Http; | |
using System.Threading.Tasks; | |
class Program | |
{ |