Skip to content

Instantly share code, notes, and snippets.

View Flappizy's full-sized avatar

Flappizy Flappizy

View GitHub Profile
@Flappizy
Flappizy / NumberRemoval.cs
Created April 20, 2021 03:28
Algorithm Fridays
class NumberRemoval
{
public static int RemoveAllNumberOccurrence(int[] array, int numberToRemove)
{
if (array.Length == 0)
{
return 0;
}
List<int> newNum = new List<int>();
@Flappizy
Flappizy / DuplicateRemoval.cs
Created April 20, 2021 03:34
Algorithm Fridays
class DuplicateRemoval
{
public static int RemoveDuplicate(int[] numbers)
{
if (numbers.Length == 0)
{
return 0;
}
List<int> newArr = new List<int>();
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)
{
@Flappizy
Flappizy / FindELementProduct.cs
Created May 2, 2021 02:54
Find Products of each index in array excluding the index
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)
@Flappizy
Flappizy / MergeTwoClasses.cs
Last active May 12, 2021 11:02
Merge Two sorted classes
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");
@Flappizy
Flappizy / ShuffleAssembleLine.cs
Last active May 21, 2021 06:51
Shuffles Assembly Line of students
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");
}
@Flappizy
Flappizy / gist:269db0ed3cf5ac4f92aea8a7acc18249
Created September 8, 2024 15:20
Make sample network call
//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
{