├── Algorith_A_Day.Tests └── Algorith_A_Day.Tests │ ├── Algorith_A_Day - Backup.Tests.csproj │ ├── Algorith_A_Day.Tests.csproj │ ├── BinaryTree │ └── Same_Tree_LC_100_E_Tests.cs │ ├── DP │ └── Climbing_Stairs_LC_70_E_DPTests.cs │ ├── DesignOnes │ └── Design_Parking_System_LC_1603_ETests.cs │ ├── FromCompanies │ └── LyftronTests.cs │ ├── Multidimensional_Arrays │ └── Kth_Smallest_Element_in__Sorted_Matrix_LC_378_MTests.cs │ ├── Patterns │ └── MergeIntervals │ │ └── InsertInterval │ │ └── Insert_Interval_LC_57_M_Tests.cs │ ├── RandomEasy │ ├── Add_Binary_67_LC_ETests.cs │ ├── Goal_Parser_Interpretation_LC_1678_E_Tests.cs │ ├── How___Number_LC_1365_E_Tests.cs │ ├── Majority_Element_LC_169_E_Tests.cs │ ├── Merge_Alternately_LC_1768_E_Tests.cs │ ├── Number_of_Steps_to_Zero_LC_1342_E_Tests.cs │ ├── Richest_Customer_Wealth_LC_1672_E_Tests.cs │ ├── Shuffle_String_LC_1528_E_Tests.cs │ └── Sum__Array_1685_LC_M_Tests.cs │ ├── bin │ └── Debug │ │ └── net5.0 │ │ ├── Algorith_A_Day.Tests.deps.json │ │ ├── Algorith_A_Day.Tests.dll │ │ ├── Algorith_A_Day.Tests.pdb │ │ ├── Algorith_A_Day.Tests.runtimeconfig.dev.json │ │ ├── Algorith_A_Day.Tests.runtimeconfig.json │ │ ├── Algorithm_A_Day.deps.json │ │ ├── Algorithm_A_Day.dll │ │ ├── Algorithm_A_Day.exe │ │ ├── Algorithm_A_Day.pdb │ │ ├── Algorithm_A_Day.runtimeconfig.dev.json │ │ ├── Algorithm_A_Day.runtimeconfig.json │ │ ├── Microsoft.TestPlatform.CommunicationUtilities.dll │ │ ├── Microsoft.TestPlatform.CoreUtilities.dll │ │ ├── Microsoft.TestPlatform.CrossPlatEngine.dll │ │ ├── Microsoft.TestPlatform.PlatformAbstractions.dll │ │ ├── Microsoft.TestPlatform.Utilities.dll │ │ ├── Microsoft.VisualStudio.CodeCoverage.Shim.dll │ │ ├── Microsoft.VisualStudio.TestPlatform.Common.dll │ │ ├── Microsoft.VisualStudio.TestPlatform.ObjectModel.dll │ │ ├── Newtonsoft.Json.dll │ │ ├── NuGet.Frameworks.dll │ │ ├── cs │ │ ├── Microsoft.TestPlatform.CommunicationUtilities.resources.dll │ │ ├── Microsoft.TestPlatform.CoreUtilities.resources.dll │ │ ├── Microsoft.TestPlatform.CrossPlatEngine.resources.dll │ │ ├── Microsoft.VisualStudio.TestPlatform.Common.resources.dll │ │ └── Microsoft.VisualStudio.TestPlatform.ObjectModel.resources.dll │ │ ├── de │ │ ├── Microsoft.TestPlatform.CommunicationUtilities.resources.dll │ │ ├── Microsoft.TestPlatform.CoreUtilities.resources.dll │ │ ├── Microsoft.TestPlatform.CrossPlatEngine.resources.dll │ │ ├── Microsoft.VisualStudio.TestPlatform.Common.resources.dll │ │ └── Microsoft.VisualStudio.TestPlatform.ObjectModel.resources.dll │ │ ├── es │ │ ├── Microsoft.TestPlatform.CommunicationUtilities.resources.dll │ │ ├── Microsoft.TestPlatform.CoreUtilities.resources.dll │ │ ├── Microsoft.TestPlatform.CrossPlatEngine.resources.dll │ │ ├── Microsoft.VisualStudio.TestPlatform.Common.resources.dll │ │ └── Microsoft.VisualStudio.TestPlatform.ObjectModel.resources.dll │ │ ├── fr │ │ ├── Microsoft.TestPlatform.CommunicationUtilities.resources.dll │ │ ├── Microsoft.TestPlatform.CoreUtilities.resources.dll │ │ ├── Microsoft.TestPlatform.CrossPlatEngine.resources.dll │ │ ├── Microsoft.VisualStudio.TestPlatform.Common.resources.dll │ │ └── Microsoft.VisualStudio.TestPlatform.ObjectModel.resources.dll │ │ ├── it │ │ ├── Microsoft.TestPlatform.CommunicationUtilities.resources.dll │ │ ├── Microsoft.TestPlatform.CoreUtilities.resources.dll │ │ ├── Microsoft.TestPlatform.CrossPlatEngine.resources.dll │ │ ├── Microsoft.VisualStudio.TestPlatform.Common.resources.dll │ │ └── Microsoft.VisualStudio.TestPlatform.ObjectModel.resources.dll │ │ ├── ja │ │ ├── Microsoft.TestPlatform.CommunicationUtilities.resources.dll │ │ ├── Microsoft.TestPlatform.CoreUtilities.resources.dll │ │ ├── Microsoft.TestPlatform.CrossPlatEngine.resources.dll │ │ ├── Microsoft.VisualStudio.TestPlatform.Common.resources.dll │ │ └── Microsoft.VisualStudio.TestPlatform.ObjectModel.resources.dll │ │ ├── ko │ │ ├── Microsoft.TestPlatform.CommunicationUtilities.resources.dll │ │ ├── Microsoft.TestPlatform.CoreUtilities.resources.dll │ │ ├── Microsoft.TestPlatform.CrossPlatEngine.resources.dll │ │ ├── Microsoft.VisualStudio.TestPlatform.Common.resources.dll │ │ └── Microsoft.VisualStudio.TestPlatform.ObjectModel.resources.dll │ │ ├── pl │ │ ├── Microsoft.TestPlatform.CommunicationUtilities.resources.dll │ │ ├── Microsoft.TestPlatform.CoreUtilities.resources.dll │ │ ├── Microsoft.TestPlatform.CrossPlatEngine.resources.dll │ │ ├── Microsoft.VisualStudio.TestPlatform.Common.resources.dll │ │ └── Microsoft.VisualStudio.TestPlatform.ObjectModel.resources.dll │ │ ├── pt-BR │ │ ├── Microsoft.TestPlatform.CommunicationUtilities.resources.dll │ │ ├── Microsoft.TestPlatform.CoreUtilities.resources.dll │ │ ├── Microsoft.TestPlatform.CrossPlatEngine.resources.dll │ │ ├── Microsoft.VisualStudio.TestPlatform.Common.resources.dll │ │ └── Microsoft.VisualStudio.TestPlatform.ObjectModel.resources.dll │ │ ├── ref │ │ └── Algorith_A_Day.Tests.dll │ │ ├── ru │ │ ├── Microsoft.TestPlatform.CommunicationUtilities.resources.dll │ │ ├── Microsoft.TestPlatform.CoreUtilities.resources.dll │ │ ├── Microsoft.TestPlatform.CrossPlatEngine.resources.dll │ │ ├── Microsoft.VisualStudio.TestPlatform.Common.resources.dll │ │ └── Microsoft.VisualStudio.TestPlatform.ObjectModel.resources.dll │ │ ├── testhost.dll │ │ ├── testhost.exe │ │ ├── tr │ │ ├── Microsoft.TestPlatform.CommunicationUtilities.resources.dll │ │ ├── Microsoft.TestPlatform.CoreUtilities.resources.dll │ │ ├── Microsoft.TestPlatform.CrossPlatEngine.resources.dll │ │ ├── Microsoft.VisualStudio.TestPlatform.Common.resources.dll │ │ └── Microsoft.VisualStudio.TestPlatform.ObjectModel.resources.dll │ │ ├── xunit.abstractions.dll │ │ ├── xunit.assert.dll │ │ ├── xunit.core.dll │ │ ├── xunit.execution.dotnet.dll │ │ ├── xunit.runner.reporters.netcoreapp10.dll │ │ ├── xunit.runner.utility.netcoreapp10.dll │ │ ├── xunit.runner.visualstudio.dotnetcore.testadapter.dll │ │ ├── zh-Hans │ │ ├── Microsoft.TestPlatform.CommunicationUtilities.resources.dll │ │ ├── Microsoft.TestPlatform.CoreUtilities.resources.dll │ │ ├── Microsoft.TestPlatform.CrossPlatEngine.resources.dll │ │ ├── Microsoft.VisualStudio.TestPlatform.Common.resources.dll │ │ └── Microsoft.VisualStudio.TestPlatform.ObjectModel.resources.dll │ │ └── zh-Hant │ │ ├── Microsoft.TestPlatform.CommunicationUtilities.resources.dll │ │ ├── Microsoft.TestPlatform.CoreUtilities.resources.dll │ │ ├── Microsoft.TestPlatform.CrossPlatEngine.resources.dll │ │ ├── Microsoft.VisualStudio.TestPlatform.Common.resources.dll │ │ └── Microsoft.VisualStudio.TestPlatform.ObjectModel.resources.dll │ └── obj │ ├── Algorith_A_Day.Tests.csproj.nuget.dgspec.json │ ├── Algorith_A_Day.Tests.csproj.nuget.g.props │ ├── Algorith_A_Day.Tests.csproj.nuget.g.targets │ ├── Debug │ ├── net5.0 │ │ ├── .NETCoreApp,Version=v5.0.AssemblyAttributes.cs │ │ ├── Algorith_A_Day.Tests.AssemblyInfo.cs │ │ ├── Algorith_A_Day.Tests.AssemblyInfoInputs.cache │ │ ├── Algorith_A_Day.Tests.GeneratedMSBuildEditorConfig.editorconfig │ │ ├── Algorith_A_Day.Tests.assets.cache │ │ ├── Algorith_A_Day.Tests.csproj.AssemblyReference.cache │ │ ├── Algorith_A_Day.Tests.csproj.CopyComplete │ │ ├── Algorith_A_Day.Tests.csproj.CoreCompileInputs.cache │ │ ├── Algorith_A_Day.Tests.csproj.FileListAbsolute.txt │ │ ├── Algorith_A_Day.Tests.dll │ │ ├── Algorith_A_Day.Tests.genruntimeconfig.cache │ │ ├── Algorith_A_Day.Tests.pdb │ │ └── ref │ │ │ └── Algorith_A_Day.Tests.dll │ └── netcoreapp3.1 │ │ ├── .NETCoreApp,Version=v3.1.AssemblyAttributes.cs │ │ ├── Algorith_A_Day.Tests.AssemblyInfo.cs │ │ ├── Algorith_A_Day.Tests.AssemblyInfoInputs.cache │ │ ├── Algorith_A_Day.Tests.assets.cache │ │ └── Algorith_A_Day.Tests.csprojAssemblyReference.cache │ ├── project.assets.json │ └── project.nuget.cache └── Algorith_A_Day ├── .gitattributes ├── .gitignore ├── Algorithm_A_Day.csproj ├── Algorithm_A_Day.sln ├── Algorithms └── Kadane's │ └── Maximum_Subarray_LC_53_E.cs ├── Arrays ├── Find_Numbers_with_Even_Number_of_Digits_1295.cs ├── Kids_With_Candies_LC_1431_E.cs ├── Merge_Sorted_Array_88.cs ├── Pairs with Specific Difference - pramp.cs ├── Pancake_Sorting_LC_969.cs ├── Running_Sum_of1d_Array_LC_1480_E.cs ├── Shuffle_the_Array_LC_1470_E.cs └── Temperatures Codingame.cs ├── Backtracking └── Letter_Combinations_of_P_Number_LC_17_M.cs ├── Basics ├── CollatzConjecture.cs ├── Factorial.cs ├── Fibonacci.cs └── Palindrome.cs ├── BinarySearch ├── BinarySearch.cs ├── ExponentialSearch.cs ├── FindFirstOccurrence.cs ├── FindFloorOrCeil.cs ├── FindNumberOfOnes.cs ├── FindPeakElement.cs ├── FindTargetNumber.cs ├── NumberOfRoatations.cs ├── SearchInNearlySorted.cs ├── Search_Insert_Position_LC_35.cs └── SmallestMissingElement.cs ├── BinaryTree ├── AdvancedBT.cs ├── BinarySearchTree.cs ├── BinaryTreeTraverasals.cs ├── LeavesOfBt.cs ├── MiddleLvlBinaryTree.cs ├── Same_Tree_LC_100_E.cs └── TreeNode.cs ├── BitManipulation └── Binary_Watch_401.cs ├── Clash_of_Code └── Ip_Address.cs ├── DP ├── Climbing_Stairs_LC_70_E_DP.cs └── Delete_Operation_for_Two_Strings_LC_583.cs ├── DesignOnes ├── Design_Ordered_Stream_LC_1656_E.cs └── Design_Parking_System_LC_1603_E.cs ├── EASY_WORTH_RECALLING.txt ├── Extensions └── Extension Methods.cs ├── FromCompanies ├── Codility.cs └── Lyftron.cs ├── JS └── helper.js ├── MathRelated ├── Count_Primes_LC_204.cs ├── Pramp │ └── Root_Of_Number.cs └── Sqrt(x)_LC_69.cs ├── Multidimensional Arrays ├── Ada King CodeChef.cs ├── Kth_Smallest_Element_in_ Sorted_Matrix_LC_378_M.cs ├── Matrixes.cs ├── Power of Thor - Episode 1 - Codoingame.cs ├── Rotate_Image_LC_48.cs ├── Spiral_Matrix_II_59.cs └── Spiral_Matrix_LC_54.cs ├── NodesModels ├── ListNode.cs ├── Node.cs └── TreeNode.cs ├── Patterns ├── 2Pointers │ ├── 3Sum_Closest_LC_16.cs │ ├── 3Sum_LC_15.cs │ ├── Intersection_of_Two_Arrays_II_LC_350.cs │ ├── Intersection_of_Two_Arrays_LC_349.cs │ ├── RemoveElement LC - 27.cs │ ├── Remove_Duplicates_from_Sorted Array_LC_26.cs │ ├── Squares of a Sorted Array - LeedCode 977.cs │ ├── Two Sum - LeetCode 1.cs │ └── Valid Palindrome II LeetCode680.cs ├── BFS │ ├── Average_of_Levels_in_Binary_Tree_LC_637.cs │ ├── Level Order_Traversal.cs │ ├── Level Order_Traversal_ 2.cs │ ├── Minimum_Depth_Binary_Tree_LC_111.cs │ └── Rotting Oranges.cs ├── CyclicSort │ ├── Find_All_Duplicates_in_Array_442.cs │ ├── Find_All_Numbers_Disappeared_In_Array_LC_448.cs │ ├── Missing_Number_LC_268.cs │ └── Set_Mismatch_LC_645.cs ├── DFS │ ├── Binary_Tree_Paths.cs │ ├── Number_Of_Islands_LC_200.cs │ ├── Path_Sum_II_LC_113.cs │ └── Path_Sum_LC-112.cs ├── DP-01Knapsack │ └── Partition_Equal_Subset_Sum_LC_416.cs ├── FastAndSlowPointers │ ├── Happy_Number.cs │ ├── Link_List_Cycle_LC_141.cs │ └── Middle_of_Linked_List_LC_876.cs ├── K-thLargestElement │ ├── K_Closest_Points_to_Origin_LC_973.cs │ └── Kth_Largest_Element.cs ├── K-way Merge │ └── Merge_k_Sorted_Lists.cs ├── MergeIntervals │ ├── InsertInterval │ │ ├── Insert Interval_LC_57_M.cs │ │ └── InsertInterval_LC_57_M.js │ └── Merge_Intervals_LC_56.cs ├── ModifiedBinarySearch │ ├── Binary_Search_LC_704.cs │ └── Find_Smallest_Letter_Greater_Than_Target_LC_744.cs ├── ReverseLinkedList │ ├── Reverse_Linked_List_II_LC_92.cs │ └── Reverse_Linked_List_LC_206.cs ├── Sliding Window │ ├── Fruit Into Baskets_LC_904.cs │ ├── Longest Substring with K Distinct Characters.cs │ ├── Longest_Repeating_Character_Replacement_LC_424.cs │ ├── Longest_Substring_Without_Repeating_Characters_LC_3.cs │ ├── Maximum Sum Subarray of Size K.cs │ ├── Permutation_in_String_LC_567.cs │ ├── Sliding Window.cs │ └── Smallest Subarray with a given sum_LC_209.cs └── Subsets │ ├── Subsets_II_LC_90.cs │ └── Subsets_LC_78.cs ├── Program.cs ├── RandomEasy ├── Add_Binary_67_LC_E.cs ├── Build_Array_from_Permutation_LC_1920_E.cs ├── Check_Equivalent_1662_LC_E.cs ├── Contains_Duplicate_LC_217_E.cs ├── Convert_Sorted_Array_to_BST_LC_108_E.cs ├── Count_Matrix_LC_1351_E.cs ├── Create_Order_1389_LC_E.cs ├── Decompress_Run_Length_Encoded_List_LC_1313_E.cs ├── Defanging_an_IP_Address_1108_E.cs ├── Fizz_Buzz_LC_412_E.cs ├── Goal_Parser_Interpretation_LC_1678_E.cs ├── How___Number_LC_1365_E.cs ├── Integer_to_Roman_LC_12.cs ├── Jewels_and_Stones_LC_771_E.cs ├── Keyboard_Row_LC_500_E.cs ├── Length_of_Last_Word_LC_58_E.cs ├── Majority_Element_LC_169_E.cs ├── Merge_Alternately_LC_1768_E.cs ├── Merge_Two_Sorted_L_Lists_LC_21.cs ├── Number__Square_1725_LC_E.cs ├── Number_of_Good_Pairs_1512_LC_E.cs ├── Number_of_Segments_in_a_String_LC_434_E.cs ├── Number_of_Steps_to_Zero_LC_1342_E.cs ├── Palindrome_Number_9.cs ├── Plus_One_66_LC_E.cs ├── Richest_Customer_Wealth_LC_1672_E.cs ├── Roman_to_Integer_LC_13.cs ├── Self_Dividing_Numbers_LC_728_E.cs ├── Shuffle_String_LC_1528_E.cs ├── Single_Number_LC_136.cs ├── Subtract_Integer_1281_LC_E.cs ├── Sum_Subarrays_LC _1588_E.cs ├── Unique_Email_Addresses_LC_929_E.cs ├── Unique_Morse_Code_Words_LC_804_E.cs └── Valid_Parentheses_LC_20_E.cs ├── RandomMedium ├── Majority_Element_II_LC_229_M.cs └── Sum_ Array_1685_LC_M.cs ├── Recursion ├── N-th_Tribonacci_Number_1137.cs ├── Reverse_String_LC_344_E.cs └── Swap_Nodes_in_Pairs_LC_24_M.cs ├── RecursiveToDeal ├── IDKrecursiveMethods.cs ├── Int_To_Roman_LC_12_Recursion.cs └── RecursionToUnderstand.cs ├── Sorting ├── BubbleSort │ ├── BubbleSortPlain.cs │ └── SortColors.cs ├── InsertionSort │ └── Insertion sort.cs ├── MergeSort │ ├── MS with 2 arrays.cs │ └── MergeSort.cs ├── Quick Sort │ └── QuickSort.cs └── SelectionSort │ └── SelectionSort.cs └── String operations ├── Implement_strStr_LC_28.cs ├── Longest Sub-String.cs ├── Pramp ├── Longest_Common_Prefix_LC_14.cs └── Smallest_Substring_Of_All_Chars.cs └── RevertAString.cs /Algorith_A_Day.Tests/Algorith_A_Day.Tests/Algorith_A_Day - Backup.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net5.0 5 | 6 | false 7 | 8 | 9 | 10 | 11 | 12 | 13 | runtime; build; native; contentfiles; analyzers; buildtransitive 14 | all 15 | 16 | 17 | runtime; build; native; contentfiles; analyzers; buildtransitive 18 | all 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/Algorith_A_Day.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net5.0 5 | 6 | false 7 | 8 | 9 | 10 | 11 | 12 | 13 | runtime; build; native; contentfiles; analyzers; buildtransitive 14 | all 15 | 16 | 17 | runtime; build; native; contentfiles; analyzers; buildtransitive 18 | all 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/BinaryTree/Same_Tree_LC_100_E_Tests.cs: -------------------------------------------------------------------------------- 1 | using Algorithm_A_Day.BinaryTree; 2 | using Algorithm_A_Day.NodesModels; 3 | using System; 4 | using System.Collections; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using Xunit; 10 | 11 | namespace Algorith_A_Day.Tests.BinaryTree 12 | { 13 | public class Same_Tree_LC_100_E_Tests 14 | { 15 | private readonly Same_Tree_LC_100_E _sut; 16 | 17 | public Same_Tree_LC_100_E_Tests() 18 | { 19 | _sut = new Same_Tree_LC_100_E(); 20 | } 21 | 22 | [Theory] 23 | [ClassData(typeof(SameTreeTestData))] 24 | public void IsSameTree_ReturnsBool_When2TreeNodesPassed(bool expected, TreeNode t1, TreeNode t2) 25 | { 26 | //Arrange 27 | 28 | //Act 29 | var actual = _sut.IsSameTree(t1, t2); 30 | //Assert 31 | Assert.Equal(expected, actual); 32 | } 33 | } 34 | 35 | public class SameTreeTestData : IEnumerable 36 | { 37 | public IEnumerator GetEnumerator() 38 | { 39 | yield return new object[] { true, new TreeNode(1, new TreeNode(2, null, null), new TreeNode(3, null, null)), 40 | new TreeNode(1, new TreeNode(2, null, null), new TreeNode(3, null, null)) }; 41 | yield return new object[] { false, new TreeNode(1, new TreeNode(2, null, null), new TreeNode(1, null, null)), 42 | new TreeNode(1, new TreeNode(1, null, null), new TreeNode(2, null, null)) }; 43 | yield return new object[] { false, new TreeNode(1, new TreeNode(2, null, null)), 44 | new TreeNode(1, null, new TreeNode(2, null, null)) }; 45 | yield return new object[] { false, null, new TreeNode(1, null, new TreeNode(2, null, null)) }; 46 | yield return new object[] { false, new TreeNode(1, null, new TreeNode(2, null, null)), null }; 47 | } 48 | 49 | IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/DP/Climbing_Stairs_LC_70_E_DPTests.cs: -------------------------------------------------------------------------------- 1 | using Algorithm_A_Day.DP; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using Xunit; 8 | 9 | namespace Algorith_A_Day.Tests.DP 10 | { 11 | public class Climbing_Stairs_LC_70_E_DPTests 12 | { 13 | private readonly Climbing_Stairs_LC_70_E_DP _sut; 14 | 15 | public Climbing_Stairs_LC_70_E_DPTests() 16 | { 17 | _sut = new Climbing_Stairs_LC_70_E_DP(); 18 | } 19 | 20 | [Theory] 21 | [InlineData(1, 0)] 22 | [InlineData(2, 2)] 23 | [InlineData(3, 3)] 24 | [InlineData(8, 5)] 25 | public void ClimbStairs_ShouldReturnsInt_WhenPositiveIntPassed(int expected, int n) 26 | { 27 | //Arrange 28 | //Act 29 | var actual = _sut.ClimbStairs(n); 30 | //Assert 31 | Assert.Equal(expected, actual); 32 | } 33 | 34 | [Theory] 35 | [InlineData(0, -1)] 36 | [InlineData(0, -3)] 37 | public void ClimbStairs_ShouldReturnsZero_WhenNegativeIntPassed(int expected, int n) 38 | { 39 | //Arrange 40 | //Act 41 | var actual = _sut.ClimbStairs(n); 42 | //Assert 43 | Assert.Equal(expected, actual); 44 | } 45 | 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/DesignOnes/Design_Parking_System_LC_1603_ETests.cs: -------------------------------------------------------------------------------- 1 |  2 | using Algorithm_A_Day.DesignOnes; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | using Xunit; 9 | 10 | namespace Algorith_A_Day.Tests.DesignOnes 11 | { 12 | public class Design_Parking_System_LC_1603_ETests 13 | { 14 | private Design_Parking_System_LC_1603_E _sut; 15 | 16 | public Design_Parking_System_LC_1603_ETests() 17 | { 18 | _sut = new Design_Parking_System_LC_1603_E(1, 1, 0); 19 | } 20 | 21 | [Fact] 22 | public void AddCar_ReturnsFalse_WhenThereIsRoomNoLeftForAnotherBigCar() 23 | { 24 | //Arrange 25 | _sut.AddCar(1); 26 | _sut.AddCar(2); 27 | _sut.AddCar(3); 28 | //Act 29 | var actual = _sut.AddCar(1); 30 | //Assert 31 | Assert.False(actual); 32 | } 33 | 34 | [Fact] 35 | public void AddCar_ReturnsTrue_WhenAllCarHaveRoom() 36 | { 37 | //Arrange 38 | _sut = new Design_Parking_System_LC_1603_E(1, 1, 1); 39 | 40 | //Act 41 | var actual_small = _sut.AddCar(1); 42 | var actual_medium = _sut.AddCar(2); 43 | var actual_big = _sut.AddCar(3); 44 | //Assert 45 | Assert.True(actual_small); 46 | Assert.True(actual_medium); 47 | Assert.True(actual_big); 48 | } 49 | 50 | [Fact] 51 | public void AddCar_ReturnsTrue_WhenNoRoomForCarsAtBeginning() 52 | { 53 | //Arrange 54 | _sut = new Design_Parking_System_LC_1603_E(0, 0, 0); 55 | 56 | //Act 57 | var actual_small = _sut.AddCar(1); 58 | var actual_medium = _sut.AddCar(2); 59 | var actual_big = _sut.AddCar(3); 60 | //Assert 61 | Assert.False(actual_small); 62 | Assert.False(actual_medium); 63 | Assert.False(actual_big); 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/Multidimensional_Arrays/Kth_Smallest_Element_in__Sorted_Matrix_LC_378_MTests.cs: -------------------------------------------------------------------------------- 1 | using Algorithm_A_Day.Multidimensional_Arrays; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using Xunit; 8 | 9 | namespace Algorith_A_Day.Tests.Multidimensional_Arrays 10 | { 11 | public class Kth_Smallest_Element_in__Sorted_Matrix_LC_378_MTests 12 | { 13 | private readonly Kth_Smallest_Element_in__Sorted_Matrix_LC_378_M _sut; 14 | 15 | public Kth_Smallest_Element_in__Sorted_Matrix_LC_378_MTests() 16 | { 17 | _sut = new Kth_Smallest_Element_in__Sorted_Matrix_LC_378_M(); 18 | } 19 | 20 | [Theory] 21 | [InlineData(13, 8)] 22 | public void KthSmallest_ReturnInt_WhenNoduplicates(int expected, int k) 23 | { 24 | //Arrange 25 | var matrix = new int[][] { new int[] { 1, 5, 9 }, new int[] { 10, 11, 13 }, new int[] { 12, 13, 15 } }; 26 | //Act 27 | var actual =_sut.KthSmallest1(matrix, k); 28 | //Assert 29 | Assert.Equal(expected, actual); 30 | } 31 | [Theory] 32 | [InlineData(1, 2)] 33 | public void KthSmallest_ReturnInt_WhenWithDuplicates(int expected, int k) 34 | { 35 | //Arrange 36 | var matrix = new int[][] { new int[] { 1, 2}, new int[] { 1, 3} }; 37 | //Act 38 | var actual =_sut.KthSmallest1(matrix, k); 39 | //Assert 40 | Assert.Equal(expected, actual); 41 | } 42 | 43 | [Theory] 44 | [InlineData(0, 8)] 45 | public void KthSmallest_Return0_WhenMatrixIsNullOrEmpty(int expected, int k) 46 | { 47 | //Arrange 48 | var matrix = Array.Empty(); 49 | int[][] matrix2 = null; 50 | //Act 51 | // bad practice but for some reason can't pass matrix as a parameter here 52 | var actual = _sut.KthSmallest1(matrix, k); 53 | var actual2 = _sut.KthSmallest1(matrix2, k); 54 | //Assert 55 | Assert.Equal(expected, actual); 56 | Assert.Equal(expected, actual2); 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/Patterns/MergeIntervals/InsertInterval/Insert_Interval_LC_57_M_Tests.cs: -------------------------------------------------------------------------------- 1 | using Algorithm_A_Day.Patterns.MergeIntervals.InsertInterval; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using Xunit; 8 | 9 | namespace Algorith_A_Day.Tests.Patterns.MergeIntervals.InsertInterval 10 | { 11 | public class Insert_Interval_LC_57_M_Tests 12 | { 13 | private readonly Insert_Interval_LC_57_M _sut; 14 | public Insert_Interval_LC_57_M_Tests() 15 | { 16 | _sut = new Insert_Interval_LC_57_M(); 17 | } 18 | 19 | 20 | [Fact] 21 | public void Insert_ReturnsMatrixWithNewInterval_WhenEmptyintervalsPassed() 22 | { 23 | //Arrange 24 | var intervals = new int[][] { }; 25 | var newInterval = new int[] { 2, 5 }; 26 | 27 | var expected = new int[][] { newInterval }; 28 | 29 | //Act 30 | var actual = _sut.Insert(intervals, newInterval ); 31 | 32 | //Assert 33 | Assert.Equal(expected, actual); 34 | } 35 | 36 | [Fact] 37 | public void Insert_ReturnsMergedMatrix_WhenProperIntervalsPassed() 38 | { 39 | //Arrange 40 | var intervals1 = new int[][] { new int[] { 1, 3 }, new int[] { 6, 9 } }; 41 | var intervals2 = new int[][] { new int[] { 1, 2 }, new int[] { 3, 5 }, 42 | new int[] { 6, 7 }, new int[] { 8, 10 }, 43 | new int[] { 12, 16 } }; 44 | var expected1 = new int[][] { new int[] { 1, 5 }, new int[] { 6, 9 } }; 45 | var expected2 = new int[][] { new int[] { 1, 2 }, new int[] { 3, 10 }, 46 | new int[] { 12, 16 } }; 47 | 48 | //Act 49 | var actual1 = _sut.Insert(intervals1, new int[] { 2, 5 }); 50 | var actual2 = _sut.Insert(intervals2, new int[] { 4, 8 }); 51 | //Assert 52 | Assert.Equal(expected1, actual1); 53 | Assert.Equal(expected2, actual2); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/RandomEasy/Add_Binary_67_LC_ETests.cs: -------------------------------------------------------------------------------- 1 | using Algorithm_A_Day.RandomEasy; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using Xunit; 8 | 9 | namespace Algorith_A_Day.Tests.RandomEasy 10 | { 11 | public class Add_Binary_67_LC_ETests 12 | { 13 | private readonly Add_Binary_67_LC_E _sut; 14 | public Add_Binary_67_LC_ETests() 15 | { 16 | _sut = new Add_Binary_67_LC_E(); 17 | } 18 | 19 | 20 | [Theory] 21 | [InlineData("11", "1", "100")] 22 | [InlineData("1010", "1011", "10101")] 23 | public void AddBinary_ReturnsString_When2ProperStringsPassed(string a, string b, string expected) 24 | { 25 | //Arrange 26 | 27 | //Act 28 | var actual = _sut.AddBinary(a, b); 29 | //Assert 30 | Assert.Equal(expected, actual); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/RandomEasy/Goal_Parser_Interpretation_LC_1678_E_Tests.cs: -------------------------------------------------------------------------------- 1 | using Algorithm_A_Day.RandomEasy; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using Xunit; 8 | 9 | namespace Algorith_A_Day.Tests.RandomEasy 10 | { 11 | public class Goal_Parser_Interpretation_LC_1678_E_Tests 12 | { 13 | private Goal_Parser_Interpretation_LC_1678_E _sut; 14 | public Goal_Parser_Interpretation_LC_1678_E_Tests() 15 | { 16 | _sut = new Goal_Parser_Interpretation_LC_1678_E(); 17 | } 18 | 19 | 20 | [Theory] 21 | [InlineData("Goal", "G()(al)")] 22 | [InlineData("Gooooal", "G()()()()(al)")] 23 | [InlineData("alGalooG", "(al)G(al)()()G")] 24 | public void Interpret_ReturnsValidString_WhenValidStringPassed(string expected, string command) 25 | { 26 | //Arrange 27 | 28 | //Act 29 | var actual = _sut.Interpret(command); 30 | //Assert 31 | Assert.Equal(expected, actual); 32 | } 33 | 34 | 35 | [Theory] 36 | [InlineData("", null)] 37 | [InlineData("", "")] 38 | public void Interpret_ReturnsEmptyString_WhenEmptyOrNullPassed(string expected, string command) 39 | { 40 | //Arrange 41 | 42 | //Act 43 | var actual = _sut.Interpret(command); 44 | //Assert 45 | Assert.Equal(expected, actual); 46 | } 47 | 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/RandomEasy/How___Number_LC_1365_E_Tests.cs: -------------------------------------------------------------------------------- 1 | using Algorithm_A_Day.RandomEasy; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using Xunit; 8 | 9 | namespace Algorith_A_Day.Tests.RandomEasy 10 | { 11 | 12 | //Arrange 13 | 14 | //Act 15 | 16 | //Assert 17 | public class How___Number_LC_1365_E_Tests 18 | { 19 | private readonly How___Number_LC_1365_E _sut; 20 | public How___Number_LC_1365_E_Tests() 21 | { 22 | _sut = new How___Number_LC_1365_E(); 23 | } 24 | 25 | 26 | [Theory] 27 | [InlineData(new int[] { 4, 0, 1, 1, 3 }, new int[] { 8, 1, 2, 2, 3 })] 28 | [InlineData(new int[] { 0, 0, 0, 0 }, new int[] { 7, 7, 7, 7 })] 29 | public void SmallerNumbersThanCurrent_ReturnsArray_WhenValidArrIsPassed(int[] expected, int[] nums) 30 | { 31 | //Arrange 32 | 33 | //Act 34 | var result = _sut.SmallerNumbersThanCurrent(nums); 35 | //Assert 36 | Assert.Equal(expected, result); 37 | } 38 | 39 | [Theory] 40 | [InlineData(new int[] { }, new int[] { })] 41 | [InlineData(new int[] { }, null)] 42 | public void SmallerNumbersThanCurrent_ReturnsEmptyArray_WhenInEmptyArrOrNullIsPassed(int[] expected, int[] nums) 43 | { 44 | //Arrange 45 | 46 | //Act 47 | var result = _sut.SmallerNumbersThanCurrent(nums); 48 | //Assert 49 | Assert.Equal(expected, result); 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/RandomEasy/Majority_Element_LC_169_E_Tests.cs: -------------------------------------------------------------------------------- 1 | using Algorithm_A_Day.RandomEasy; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using Xunit; 8 | 9 | namespace Algorith_A_Day.Tests.RandomEasy 10 | { 11 | public class Majority_Element_LC_169_E_Tests 12 | { 13 | private readonly Majority_Element_LC_169_E _sut; 14 | 15 | public Majority_Element_LC_169_E_Tests() 16 | { 17 | _sut = new Majority_Element_LC_169_E(); 18 | } 19 | 20 | [Theory] 21 | [InlineData(3, new int[] { 3, 2, 3 })] 22 | [InlineData(2, new int[] { 2, 2, 1, 1, 1, 2, 2 })] 23 | public void MajorityElement_ReturnsInt_WhenValidArrayPassed(int expected, int[] nums) 24 | { 25 | //Arrange 26 | 27 | //Act 28 | var actual = _sut.MajorityElement(nums); 29 | //Assert 30 | Assert.Equal(expected, actual); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/RandomEasy/Merge_Alternately_LC_1768_E_Tests.cs: -------------------------------------------------------------------------------- 1 | using Algorithm_A_Day.RandomEasy; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using Xunit; 8 | 9 | namespace Algorith_A_Day.Tests.RandomEasy 10 | { 11 | public class Merge_Alternately_LC_1768_E_Tests 12 | { 13 | private Merge_Alternately_LC_1768_E _sut; 14 | public Merge_Alternately_LC_1768_E_Tests() 15 | { 16 | _sut = new Merge_Alternately_LC_1768_E(); 17 | } 18 | 19 | [Theory] 20 | [InlineData("abc", "pqr", "apbqcr")] 21 | [InlineData("abcd", "pq", "apbqcd")] 22 | [InlineData("ab", "pqrs", "apbqrs")] 23 | [InlineData("", "xxx", "xxx")] 24 | [InlineData("xxx", "", "xxx")] 25 | 26 | public void MergeAlternately_Returns_WhenValidDataPassed(string word1, string word2, string expected) 27 | { 28 | //Arrange 29 | 30 | //Act 31 | var actual = _sut.MergeAlternately(word1, word2); 32 | //Assert 33 | Assert.Equal(expected, actual); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/RandomEasy/Number_of_Steps_to_Zero_LC_1342_E_Tests.cs: -------------------------------------------------------------------------------- 1 | using Algorithm_A_Day.RandomEasy; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using Xunit; 8 | 9 | namespace Algorith_A_Day.Tests.RandomEasy 10 | { 11 | public class Number_of_Steps_to_Zero_LC_1342_E_Tests 12 | { 13 | private readonly Number_of_Steps_to_Zero_LC_1342_E _sut; 14 | public Number_of_Steps_to_Zero_LC_1342_E_Tests() 15 | { 16 | _sut = new Number_of_Steps_to_Zero_LC_1342_E(); 17 | } 18 | 19 | [Theory] 20 | [InlineData(6, 14)] 21 | [InlineData(4, 8)] 22 | public void NumbersOfSteps_ReturnsInt_WhenNonNegativeIntPassed(int expected, int num) 23 | { 24 | //Arrange 25 | 26 | //Act 27 | var actual = _sut.NumberOfSteps(num); 28 | //Assert 29 | Assert.Equal(expected, actual); 30 | } 31 | [Theory] 32 | [InlineData(0, 0)] 33 | [InlineData(0, -2)] 34 | public void NumbersOfSteps_ReturnsZero_WhenNegativeOrZeroPassed(int expected, int num) 35 | { 36 | //Arrange 37 | 38 | //Act 39 | var actual = _sut.NumberOfSteps(num); 40 | //Assert 41 | Assert.Equal(expected, actual); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/RandomEasy/Richest_Customer_Wealth_LC_1672_E_Tests.cs: -------------------------------------------------------------------------------- 1 | using Algorithm_A_Day.RandomEasy; 2 | using System; 3 | using System.Collections; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | using Xunit; 9 | 10 | namespace Algorith_A_Day.Tests.RandomEasy 11 | { 12 | public class Richest_Customer_Wealth_LC_1672_E_Tests 13 | { 14 | private readonly Richest_Customer_Wealth_LC_1672_E _sut; 15 | public Richest_Customer_Wealth_LC_1672_E_Tests() 16 | { 17 | _sut = new Richest_Customer_Wealth_LC_1672_E(); 18 | } 19 | 20 | 21 | 22 | [Theory] 23 | [ClassData(typeof(RichestTestData))] 24 | public void MaximumWealth_MaxWealth_WhenValidMatrixPassed(int expected, int[][] accounts) 25 | { 26 | //Arrange 27 | 28 | //Act 29 | var actual = _sut.MaximumWealth(accounts); 30 | //Assert 31 | Assert.Equal(expected, actual); 32 | } 33 | 34 | [Theory] 35 | [ClassData(typeof(RichestFaultyData))] 36 | public void MaximumWealth_ReturnsZero_WhenNegativeOrZeroPassed(int expected, int[][] accounts) 37 | { 38 | //Arrange 39 | 40 | //Act 41 | var actual = _sut.MaximumWealth(accounts); 42 | //Assert 43 | Assert.Equal(expected, actual); 44 | } 45 | 46 | 47 | 48 | 49 | public class RichestTestData : IEnumerable 50 | { 51 | public IEnumerator GetEnumerator() 52 | { 53 | yield return new object[] { 10, new int[][] { new int[] { 1, 5 }, new int[] { 7, 3 }, new int[] { 3, 5 } } }; 54 | yield return new object[] { 17, new int[][] { new int[] { 2, 8, 7 }, new int[] { 7, 1, 3 }, new int[] { 1, 9, 5 } } }; 55 | yield return new object[] { 6, new int[][] { new int[] { 1, 2, 3 }, new int[] { 3, 2, 1 } } }; 56 | } 57 | 58 | IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); 59 | } 60 | 61 | public class RichestFaultyData : IEnumerable 62 | { 63 | public IEnumerator GetEnumerator() 64 | { 65 | yield return new object[] { 0, new int[][] { } }; 66 | yield return new object[] { 0, null }; 67 | 68 | } 69 | 70 | IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/RandomEasy/Shuffle_String_LC_1528_E_Tests.cs: -------------------------------------------------------------------------------- 1 | using Algorithm_A_Day.RandomEasy; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using Xunit; 8 | 9 | namespace Algorith_A_Day.Tests.RandomEasy 10 | { 11 | public class Shuffle_String_LC_1528_E_Tests 12 | { 13 | private Shuffle_String_LC_1528_E _sut; 14 | public Shuffle_String_LC_1528_E_Tests() 15 | { 16 | _sut = new Shuffle_String_LC_1528_E(); 17 | } 18 | 19 | 20 | [Theory] 21 | [InlineData("abc", "abc", new int[] { 0, 1, 2 } )] 22 | [InlineData("aiohn", "nihao", new int[] { 3, 1, 4, 2, 0 })] 23 | [InlineData("leetcode", "codeleet", new int[] { 4, 5, 6, 7, 0, 2, 1, 3 })] 24 | [InlineData("arigatou", "aaiougrt", new int[] { 4, 0, 2, 6, 7, 3, 1, 5 })] 25 | [InlineData("", "aaiougrt", new int[] { 4, 0 })] 26 | 27 | public void Interpret_ReturnsShuffledString_WhenValidDataPassed(string expected, string s, int[] indices) 28 | { 29 | //Arrange 30 | 31 | //Act 32 | var actual = _sut.RestoreString(s, indices); 33 | //Assert 34 | Assert.Equal(expected, actual); 35 | } 36 | 37 | 38 | [Theory] 39 | [InlineData("", "", new int[] { 4, 0, 2, 6, 7, 3, 1, 5 })] 40 | [InlineData("", null, new int[] { 4, 0, 2, 6, 7, 3, 1, 5 })] 41 | [InlineData("ssss", "ssss", new int[] { })] 42 | [InlineData("ssss", "ssss", null)] 43 | public void Interpret_ReturnsEmptyStringOrString_WhenEmptyOrNullPassed(string expected, string s, int[] indices) 44 | { 45 | //Arrange 46 | 47 | //Act 48 | var actual = _sut.RestoreString(s, indices); 49 | //Assert 50 | Assert.Equal(expected, actual); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/RandomEasy/Sum__Array_1685_LC_M_Tests.cs: -------------------------------------------------------------------------------- 1 | using Algorithm_A_Day.RandomMedium; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using Xunit; 8 | 9 | namespace Algorith_A_Day.Tests.RandomEasy 10 | { 11 | 12 | public class Sum__Array_1685_LC_M_Tests 13 | { 14 | private Sum__Array_1685_LC_M _sut; 15 | public Sum__Array_1685_LC_M_Tests() 16 | { 17 | _sut = new Sum__Array_1685_LC_M(); 18 | } 19 | 20 | [Theory] 21 | [InlineData(new int[] { 4, 3, 5 }, new int[] { 2, 3, 5 })] 22 | [InlineData(new int[] { 24, 15, 13, 15, 21 }, new int[] { 1, 4, 6, 8, 10 })] 23 | [InlineData(new int[] { }, new int[] { })] 24 | [InlineData(new int[] { }, null)] 25 | 26 | public void GetSumAbsoluteDifferences_ReturnsIntArray_WhenValidDataPassed(int[] expected, int[] nums) 27 | { 28 | //Arrange 29 | 30 | //Act 31 | var actual = _sut.GetSumAbsoluteDifferences(nums); 32 | //Assert 33 | Assert.Equal(expected, actual); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/Algorith_A_Day.Tests.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/Algorith_A_Day.Tests.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/Algorith_A_Day.Tests.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/Algorith_A_Day.Tests.pdb -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/Algorith_A_Day.Tests.runtimeconfig.dev.json: -------------------------------------------------------------------------------- 1 | { 2 | "runtimeOptions": { 3 | "additionalProbingPaths": [ 4 | "C:\\Users\\franek\\.dotnet\\store\\|arch|\\|tfm|", 5 | "C:\\Users\\franek\\.nuget\\packages" 6 | ] 7 | } 8 | } -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/Algorith_A_Day.Tests.runtimeconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "runtimeOptions": { 3 | "tfm": "net5.0", 4 | "framework": { 5 | "name": "Microsoft.NETCore.App", 6 | "version": "5.0.0" 7 | } 8 | } 9 | } -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/Algorithm_A_Day.deps.json: -------------------------------------------------------------------------------- 1 | { 2 | "runtimeTarget": { 3 | "name": ".NETCoreApp,Version=v5.0", 4 | "signature": "" 5 | }, 6 | "compilationOptions": {}, 7 | "targets": { 8 | ".NETCoreApp,Version=v5.0": { 9 | "Algorithm_A_Day/1.0.0": { 10 | "runtime": { 11 | "Algorithm_A_Day.dll": {} 12 | } 13 | } 14 | } 15 | }, 16 | "libraries": { 17 | "Algorithm_A_Day/1.0.0": { 18 | "type": "project", 19 | "serviceable": false, 20 | "sha512": "" 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/Algorithm_A_Day.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/Algorithm_A_Day.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/Algorithm_A_Day.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/Algorithm_A_Day.exe -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/Algorithm_A_Day.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/Algorithm_A_Day.pdb -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/Algorithm_A_Day.runtimeconfig.dev.json: -------------------------------------------------------------------------------- 1 | { 2 | "runtimeOptions": { 3 | "additionalProbingPaths": [ 4 | "C:\\Users\\franek\\.dotnet\\store\\|arch|\\|tfm|", 5 | "C:\\Users\\franek\\.nuget\\packages" 6 | ] 7 | } 8 | } -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/Algorithm_A_Day.runtimeconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "runtimeOptions": { 3 | "tfm": "net5.0", 4 | "framework": { 5 | "name": "Microsoft.NETCore.App", 6 | "version": "5.0.0" 7 | } 8 | } 9 | } -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/Microsoft.TestPlatform.CommunicationUtilities.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/Microsoft.TestPlatform.CommunicationUtilities.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/Microsoft.TestPlatform.CoreUtilities.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/Microsoft.TestPlatform.CoreUtilities.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/Microsoft.TestPlatform.CrossPlatEngine.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/Microsoft.TestPlatform.CrossPlatEngine.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/Microsoft.TestPlatform.PlatformAbstractions.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/Microsoft.TestPlatform.PlatformAbstractions.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/Microsoft.TestPlatform.Utilities.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/Microsoft.TestPlatform.Utilities.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/Microsoft.VisualStudio.CodeCoverage.Shim.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/Microsoft.VisualStudio.CodeCoverage.Shim.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/Microsoft.VisualStudio.TestPlatform.Common.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/Microsoft.VisualStudio.TestPlatform.Common.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/Microsoft.VisualStudio.TestPlatform.ObjectModel.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/Microsoft.VisualStudio.TestPlatform.ObjectModel.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/Newtonsoft.Json.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/Newtonsoft.Json.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/NuGet.Frameworks.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/NuGet.Frameworks.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/cs/Microsoft.TestPlatform.CommunicationUtilities.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/cs/Microsoft.TestPlatform.CommunicationUtilities.resources.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/cs/Microsoft.TestPlatform.CoreUtilities.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/cs/Microsoft.TestPlatform.CoreUtilities.resources.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/cs/Microsoft.TestPlatform.CrossPlatEngine.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/cs/Microsoft.TestPlatform.CrossPlatEngine.resources.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/cs/Microsoft.VisualStudio.TestPlatform.Common.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/cs/Microsoft.VisualStudio.TestPlatform.Common.resources.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/cs/Microsoft.VisualStudio.TestPlatform.ObjectModel.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/cs/Microsoft.VisualStudio.TestPlatform.ObjectModel.resources.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/de/Microsoft.TestPlatform.CommunicationUtilities.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/de/Microsoft.TestPlatform.CommunicationUtilities.resources.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/de/Microsoft.TestPlatform.CoreUtilities.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/de/Microsoft.TestPlatform.CoreUtilities.resources.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/de/Microsoft.TestPlatform.CrossPlatEngine.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/de/Microsoft.TestPlatform.CrossPlatEngine.resources.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/de/Microsoft.VisualStudio.TestPlatform.Common.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/de/Microsoft.VisualStudio.TestPlatform.Common.resources.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/de/Microsoft.VisualStudio.TestPlatform.ObjectModel.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/de/Microsoft.VisualStudio.TestPlatform.ObjectModel.resources.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/es/Microsoft.TestPlatform.CommunicationUtilities.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/es/Microsoft.TestPlatform.CommunicationUtilities.resources.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/es/Microsoft.TestPlatform.CoreUtilities.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/es/Microsoft.TestPlatform.CoreUtilities.resources.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/es/Microsoft.TestPlatform.CrossPlatEngine.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/es/Microsoft.TestPlatform.CrossPlatEngine.resources.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/es/Microsoft.VisualStudio.TestPlatform.Common.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/es/Microsoft.VisualStudio.TestPlatform.Common.resources.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/es/Microsoft.VisualStudio.TestPlatform.ObjectModel.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/es/Microsoft.VisualStudio.TestPlatform.ObjectModel.resources.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/fr/Microsoft.TestPlatform.CommunicationUtilities.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/fr/Microsoft.TestPlatform.CommunicationUtilities.resources.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/fr/Microsoft.TestPlatform.CoreUtilities.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/fr/Microsoft.TestPlatform.CoreUtilities.resources.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/fr/Microsoft.TestPlatform.CrossPlatEngine.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/fr/Microsoft.TestPlatform.CrossPlatEngine.resources.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/fr/Microsoft.VisualStudio.TestPlatform.Common.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/fr/Microsoft.VisualStudio.TestPlatform.Common.resources.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/fr/Microsoft.VisualStudio.TestPlatform.ObjectModel.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/fr/Microsoft.VisualStudio.TestPlatform.ObjectModel.resources.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/it/Microsoft.TestPlatform.CommunicationUtilities.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/it/Microsoft.TestPlatform.CommunicationUtilities.resources.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/it/Microsoft.TestPlatform.CoreUtilities.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/it/Microsoft.TestPlatform.CoreUtilities.resources.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/it/Microsoft.TestPlatform.CrossPlatEngine.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/it/Microsoft.TestPlatform.CrossPlatEngine.resources.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/it/Microsoft.VisualStudio.TestPlatform.Common.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/it/Microsoft.VisualStudio.TestPlatform.Common.resources.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/it/Microsoft.VisualStudio.TestPlatform.ObjectModel.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/it/Microsoft.VisualStudio.TestPlatform.ObjectModel.resources.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/ja/Microsoft.TestPlatform.CommunicationUtilities.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/ja/Microsoft.TestPlatform.CommunicationUtilities.resources.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/ja/Microsoft.TestPlatform.CoreUtilities.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/ja/Microsoft.TestPlatform.CoreUtilities.resources.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/ja/Microsoft.TestPlatform.CrossPlatEngine.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/ja/Microsoft.TestPlatform.CrossPlatEngine.resources.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/ja/Microsoft.VisualStudio.TestPlatform.Common.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/ja/Microsoft.VisualStudio.TestPlatform.Common.resources.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/ja/Microsoft.VisualStudio.TestPlatform.ObjectModel.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/ja/Microsoft.VisualStudio.TestPlatform.ObjectModel.resources.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/ko/Microsoft.TestPlatform.CommunicationUtilities.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/ko/Microsoft.TestPlatform.CommunicationUtilities.resources.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/ko/Microsoft.TestPlatform.CoreUtilities.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/ko/Microsoft.TestPlatform.CoreUtilities.resources.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/ko/Microsoft.TestPlatform.CrossPlatEngine.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/ko/Microsoft.TestPlatform.CrossPlatEngine.resources.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/ko/Microsoft.VisualStudio.TestPlatform.Common.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/ko/Microsoft.VisualStudio.TestPlatform.Common.resources.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/ko/Microsoft.VisualStudio.TestPlatform.ObjectModel.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/ko/Microsoft.VisualStudio.TestPlatform.ObjectModel.resources.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/pl/Microsoft.TestPlatform.CommunicationUtilities.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/pl/Microsoft.TestPlatform.CommunicationUtilities.resources.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/pl/Microsoft.TestPlatform.CoreUtilities.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/pl/Microsoft.TestPlatform.CoreUtilities.resources.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/pl/Microsoft.TestPlatform.CrossPlatEngine.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/pl/Microsoft.TestPlatform.CrossPlatEngine.resources.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/pl/Microsoft.VisualStudio.TestPlatform.Common.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/pl/Microsoft.VisualStudio.TestPlatform.Common.resources.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/pl/Microsoft.VisualStudio.TestPlatform.ObjectModel.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/pl/Microsoft.VisualStudio.TestPlatform.ObjectModel.resources.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/pt-BR/Microsoft.TestPlatform.CommunicationUtilities.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/pt-BR/Microsoft.TestPlatform.CommunicationUtilities.resources.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/pt-BR/Microsoft.TestPlatform.CoreUtilities.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/pt-BR/Microsoft.TestPlatform.CoreUtilities.resources.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/pt-BR/Microsoft.TestPlatform.CrossPlatEngine.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/pt-BR/Microsoft.TestPlatform.CrossPlatEngine.resources.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/pt-BR/Microsoft.VisualStudio.TestPlatform.Common.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/pt-BR/Microsoft.VisualStudio.TestPlatform.Common.resources.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/pt-BR/Microsoft.VisualStudio.TestPlatform.ObjectModel.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/pt-BR/Microsoft.VisualStudio.TestPlatform.ObjectModel.resources.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/ref/Algorith_A_Day.Tests.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/ref/Algorith_A_Day.Tests.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/ru/Microsoft.TestPlatform.CommunicationUtilities.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/ru/Microsoft.TestPlatform.CommunicationUtilities.resources.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/ru/Microsoft.TestPlatform.CoreUtilities.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/ru/Microsoft.TestPlatform.CoreUtilities.resources.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/ru/Microsoft.TestPlatform.CrossPlatEngine.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/ru/Microsoft.TestPlatform.CrossPlatEngine.resources.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/ru/Microsoft.VisualStudio.TestPlatform.Common.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/ru/Microsoft.VisualStudio.TestPlatform.Common.resources.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/ru/Microsoft.VisualStudio.TestPlatform.ObjectModel.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/ru/Microsoft.VisualStudio.TestPlatform.ObjectModel.resources.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/testhost.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/testhost.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/testhost.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/testhost.exe -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/tr/Microsoft.TestPlatform.CommunicationUtilities.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/tr/Microsoft.TestPlatform.CommunicationUtilities.resources.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/tr/Microsoft.TestPlatform.CoreUtilities.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/tr/Microsoft.TestPlatform.CoreUtilities.resources.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/tr/Microsoft.TestPlatform.CrossPlatEngine.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/tr/Microsoft.TestPlatform.CrossPlatEngine.resources.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/tr/Microsoft.VisualStudio.TestPlatform.Common.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/tr/Microsoft.VisualStudio.TestPlatform.Common.resources.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/tr/Microsoft.VisualStudio.TestPlatform.ObjectModel.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/tr/Microsoft.VisualStudio.TestPlatform.ObjectModel.resources.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/xunit.abstractions.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/xunit.abstractions.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/xunit.assert.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/xunit.assert.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/xunit.core.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/xunit.core.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/xunit.execution.dotnet.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/xunit.execution.dotnet.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/xunit.runner.reporters.netcoreapp10.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/xunit.runner.reporters.netcoreapp10.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/xunit.runner.utility.netcoreapp10.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/xunit.runner.utility.netcoreapp10.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/xunit.runner.visualstudio.dotnetcore.testadapter.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/xunit.runner.visualstudio.dotnetcore.testadapter.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/zh-Hans/Microsoft.TestPlatform.CommunicationUtilities.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/zh-Hans/Microsoft.TestPlatform.CommunicationUtilities.resources.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/zh-Hans/Microsoft.TestPlatform.CoreUtilities.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/zh-Hans/Microsoft.TestPlatform.CoreUtilities.resources.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/zh-Hans/Microsoft.TestPlatform.CrossPlatEngine.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/zh-Hans/Microsoft.TestPlatform.CrossPlatEngine.resources.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/zh-Hans/Microsoft.VisualStudio.TestPlatform.Common.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/zh-Hans/Microsoft.VisualStudio.TestPlatform.Common.resources.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/zh-Hans/Microsoft.VisualStudio.TestPlatform.ObjectModel.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/zh-Hans/Microsoft.VisualStudio.TestPlatform.ObjectModel.resources.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/zh-Hant/Microsoft.TestPlatform.CommunicationUtilities.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/zh-Hant/Microsoft.TestPlatform.CommunicationUtilities.resources.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/zh-Hant/Microsoft.TestPlatform.CoreUtilities.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/zh-Hant/Microsoft.TestPlatform.CoreUtilities.resources.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/zh-Hant/Microsoft.TestPlatform.CrossPlatEngine.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/zh-Hant/Microsoft.TestPlatform.CrossPlatEngine.resources.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/zh-Hant/Microsoft.VisualStudio.TestPlatform.Common.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/zh-Hant/Microsoft.VisualStudio.TestPlatform.Common.resources.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/zh-Hant/Microsoft.VisualStudio.TestPlatform.ObjectModel.resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/bin/Debug/net5.0/zh-Hant/Microsoft.VisualStudio.TestPlatform.ObjectModel.resources.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/obj/Algorith_A_Day.Tests.csproj.nuget.g.targets: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath) 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/obj/Debug/net5.0/.NETCoreApp,Version=v5.0.AssemblyAttributes.cs: -------------------------------------------------------------------------------- 1 | // 2 | using System; 3 | using System.Reflection; 4 | [assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v5.0", FrameworkDisplayName = "")] 5 | -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/obj/Debug/net5.0/Algorith_A_Day.Tests.AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | using System; 12 | using System.Reflection; 13 | 14 | [assembly: System.Reflection.AssemblyCompanyAttribute("Algorith_A_Day.Tests")] 15 | [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] 16 | [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] 17 | [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")] 18 | [assembly: System.Reflection.AssemblyProductAttribute("Algorith_A_Day.Tests")] 19 | [assembly: System.Reflection.AssemblyTitleAttribute("Algorith_A_Day.Tests")] 20 | [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] 21 | 22 | // Generated by the MSBuild WriteCodeFragment class. 23 | 24 | -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/obj/Debug/net5.0/Algorith_A_Day.Tests.AssemblyInfoInputs.cache: -------------------------------------------------------------------------------- 1 | d79fa69e98dcb4a9c82cc25b705cd3b597c30ac9 2 | -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/obj/Debug/net5.0/Algorith_A_Day.Tests.GeneratedMSBuildEditorConfig.editorconfig: -------------------------------------------------------------------------------- 1 | is_global = true 2 | build_property.TargetFramework = net5.0 3 | build_property.TargetPlatformMinVersion = 4 | build_property.UsingMicrosoftNETSdkWeb = 5 | build_property.ProjectTypeGuids = 6 | build_property.PublishSingleFile = 7 | build_property.IncludeAllContentForSelfExtract = 8 | build_property._SupportedPlatformList = Android,iOS,Linux,macOS,Windows 9 | -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/obj/Debug/net5.0/Algorith_A_Day.Tests.assets.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/obj/Debug/net5.0/Algorith_A_Day.Tests.assets.cache -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/obj/Debug/net5.0/Algorith_A_Day.Tests.csproj.AssemblyReference.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/obj/Debug/net5.0/Algorith_A_Day.Tests.csproj.AssemblyReference.cache -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/obj/Debug/net5.0/Algorith_A_Day.Tests.csproj.CopyComplete: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/obj/Debug/net5.0/Algorith_A_Day.Tests.csproj.CopyComplete -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/obj/Debug/net5.0/Algorith_A_Day.Tests.csproj.CoreCompileInputs.cache: -------------------------------------------------------------------------------- 1 | cd743117affe00d0208c25efa866729d84ed4203 2 | -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/obj/Debug/net5.0/Algorith_A_Day.Tests.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/obj/Debug/net5.0/Algorith_A_Day.Tests.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/obj/Debug/net5.0/Algorith_A_Day.Tests.genruntimeconfig.cache: -------------------------------------------------------------------------------- 1 | eb15d33a50b032aa8f7fe2108f8246becf1393ac 2 | -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/obj/Debug/net5.0/Algorith_A_Day.Tests.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/obj/Debug/net5.0/Algorith_A_Day.Tests.pdb -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/obj/Debug/net5.0/ref/Algorith_A_Day.Tests.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/obj/Debug/net5.0/ref/Algorith_A_Day.Tests.dll -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/obj/Debug/netcoreapp3.1/.NETCoreApp,Version=v3.1.AssemblyAttributes.cs: -------------------------------------------------------------------------------- 1 | // 2 | using System; 3 | using System.Reflection; 4 | [assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v3.1", FrameworkDisplayName = "")] 5 | -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/obj/Debug/netcoreapp3.1/Algorith_A_Day.Tests.AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | using System; 12 | using System.Reflection; 13 | 14 | [assembly: System.Reflection.AssemblyCompanyAttribute("Algorith_A_Day.Tests")] 15 | [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] 16 | [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] 17 | [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")] 18 | [assembly: System.Reflection.AssemblyProductAttribute("Algorith_A_Day.Tests")] 19 | [assembly: System.Reflection.AssemblyTitleAttribute("Algorith_A_Day.Tests")] 20 | [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] 21 | 22 | // Generated by the MSBuild WriteCodeFragment class. 23 | 24 | -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/obj/Debug/netcoreapp3.1/Algorith_A_Day.Tests.AssemblyInfoInputs.cache: -------------------------------------------------------------------------------- 1 | d79fa69e98dcb4a9c82cc25b705cd3b597c30ac9 2 | -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/obj/Debug/netcoreapp3.1/Algorith_A_Day.Tests.assets.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/obj/Debug/netcoreapp3.1/Algorith_A_Day.Tests.assets.cache -------------------------------------------------------------------------------- /Algorith_A_Day.Tests/Algorith_A_Day.Tests/obj/Debug/netcoreapp3.1/Algorith_A_Day.Tests.csprojAssemblyReference.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/Algorithms_Examples/d5d2df09d20d45b4e5a004b4ae7dd8dc50780653/Algorith_A_Day.Tests/Algorith_A_Day.Tests/obj/Debug/netcoreapp3.1/Algorith_A_Day.Tests.csprojAssemblyReference.cache -------------------------------------------------------------------------------- /Algorith_A_Day/Algorithm_A_Day.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | net5.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Algorith_A_Day/Algorithm_A_Day.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30114.105 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Algorithm_A_Day", "Algorithm_A_Day.csproj", "{AAFF0F5D-0C8C-48C4-AB21-5004BA276DFA}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Algorith_A_Day.Tests", "..\Algorith_A_Day.Tests\Algorith_A_Day.Tests\Algorith_A_Day.Tests.csproj", "{46AB6450-D81F-4E3F-875C-F858A0FC2EC2}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Any CPU = Debug|Any CPU 13 | Release|Any CPU = Release|Any CPU 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {AAFF0F5D-0C8C-48C4-AB21-5004BA276DFA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 17 | {AAFF0F5D-0C8C-48C4-AB21-5004BA276DFA}.Debug|Any CPU.Build.0 = Debug|Any CPU 18 | {AAFF0F5D-0C8C-48C4-AB21-5004BA276DFA}.Release|Any CPU.ActiveCfg = Release|Any CPU 19 | {AAFF0F5D-0C8C-48C4-AB21-5004BA276DFA}.Release|Any CPU.Build.0 = Release|Any CPU 20 | {46AB6450-D81F-4E3F-875C-F858A0FC2EC2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {46AB6450-D81F-4E3F-875C-F858A0FC2EC2}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {46AB6450-D81F-4E3F-875C-F858A0FC2EC2}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {46AB6450-D81F-4E3F-875C-F858A0FC2EC2}.Release|Any CPU.Build.0 = Release|Any CPU 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {5BEB27E4-A2A7-4A22-95E1-7151501C8436} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /Algorith_A_Day/Arrays/Find_Numbers_with_Even_Number_of_Digits_1295.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace Algorithm_A_Day.Arrays 7 | { 8 | public class Find_Numbers_with_Even_Number_of_Digits_1295 9 | { 10 | public static int FindNumbers(int[] nums) 11 | { 12 | if (nums.Length == 0 || nums == null) throw new Exception(); 13 | 14 | int result = 0; 15 | foreach (int num in nums) 16 | { 17 | if (num.ToString().Length % 2 == 0) result++; 18 | } 19 | return result; 20 | } 21 | 22 | //LINQ 23 | public int FindNumbers2(int[] nums) 24 | { 25 | return nums.Count(x => x.ToString().Length % 2 == 0); 26 | } 27 | 28 | // without string conversion 29 | public int FindNumbers3(int[] nums) 30 | { 31 | int evenCount = 0; 32 | int count = 0; 33 | int val = 0; 34 | 35 | for (int i = 0; i < nums.Length; i++) 36 | { 37 | count = 0; 38 | val = nums[i]; 39 | while (val > 0) { count++; val = val / 10; } 40 | if (count % 2 == 0) { evenCount++; } 41 | } 42 | 43 | return evenCount; 44 | } 45 | 46 | //math with log 47 | // todo: understand 48 | /// 49 | /// Mathematical formula for counting digits in an int value is Math.Floor(Math.Log10(n) + 1)) 50 | /// then instead of performing a % operation we can do a logical & with 1 in order to 51 | /// determine whether the number has even number of digits. 52 | /// 53 | 54 | public int FindNumbers4(int[] nums) 55 | { 56 | return nums.Count(x => x.ToString().Length % 2 == 0); 57 | } 58 | 59 | } 60 | } 61 | 62 | -------------------------------------------------------------------------------- /Algorith_A_Day/Arrays/Kids_With_Candies_LC_1431_E.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace Algorithm_A_Day.Arrays 7 | { 8 | public class Kids_With_Candies_LC_1431_E 9 | { 10 | public IList KidsWithCandies(int[] candies, int extraCandies) 11 | { 12 | List result = new List(); 13 | if (candies.Length == 0 || candies == null || extraCandies < 0) return result; 14 | 15 | int maxVal = candies.Max(); 16 | 17 | foreach (int can in candies) 18 | { 19 | if (can + extraCandies >= maxVal) 20 | { 21 | result.Add(true); 22 | } 23 | else 24 | { 25 | result.Add(false); 26 | } 27 | } 28 | return result; 29 | } 30 | 31 | public IList KidsWithCandies2(int[] candies, int extraCandies) 32 | { 33 | var max = candies.Max(); 34 | return candies.Select(c => c + extraCandies >= max).ToList(); 35 | } 36 | 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Algorith_A_Day/Arrays/Merge_Sorted_Array_88.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Algorithm_A_Day.Arrays 6 | { 7 | public class Merge_Sorted_Array_88 8 | { 9 | public static void Merge(int[] nums1, int m, int[] nums2, int n) 10 | { 11 | var len = m + n; 12 | var i1 = m - 1; 13 | var i2 = n - 1; 14 | for (int i = len - 1; i >= 0; i--) 15 | { 16 | if (i1 >= 0 && i2 >= 0) 17 | { 18 | if (nums1[i1] > nums2[i2]) 19 | { 20 | nums1[i] = nums1[i1]; 21 | i1--; 22 | } 23 | else 24 | { 25 | nums1[i] = nums2[i2]; 26 | i2--; 27 | } 28 | } 29 | else if (i1 >= 0) 30 | { 31 | nums1[i] = nums1[i1]; 32 | i1--; 33 | } 34 | else 35 | { 36 | nums1[i] = nums2[i2]; 37 | i2--; 38 | } 39 | } 40 | } 41 | 42 | public static void Merge2(int[] nums1, int m, int[] nums2, int n) 43 | { 44 | int l1 = m - 1; 45 | int l2 = n - 1; 46 | int l3 = m + n - 1; 47 | 48 | while (l2 >= 0) 49 | { 50 | if (l1 < 0 || nums2[l2] >= nums1[l1]) 51 | { 52 | nums1[l3] = nums2[l2]; 53 | l2--; 54 | } 55 | else 56 | { 57 | nums1[l3] = nums1[l1]; 58 | l1--; 59 | } 60 | l3--; 61 | 62 | } 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /Algorith_A_Day/Arrays/Running_Sum_of1d_Array_LC_1480_E.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Algorithm_A_Day.Arrays 6 | { 7 | public class Running_Sum_of1d_Array_LC_1480_E 8 | { 9 | public int[] RunningSum(int[] nums) 10 | { 11 | if (nums.Length == 0 || nums == null) return new int[] { }; 12 | int len = nums.Length; 13 | 14 | for (int i = 1; i < len; i++) 15 | { 16 | nums[i] += nums[i - 1]; 17 | } 18 | return nums; 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /Algorith_A_Day/Arrays/Shuffle_the_Array_LC_1470_E.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Algorithm_A_Day.Arrays 7 | { 8 | public class Shuffle_the_Array_LC_1470_E 9 | { 10 | public static int[] Shuffle(int[] nums, int n) 11 | { 12 | var result = new List(); 13 | if (nums.Length % 2 != 0) return result.ToArray(); 14 | int midLen = n; 15 | 16 | for (int i = 0; i < midLen; i++) 17 | { 18 | result.Add(nums[i]); 19 | result.Add(nums[n]); 20 | n++; 21 | } 22 | 23 | return result.ToArray(); 24 | } 25 | 26 | // with array [2 * i] 27 | // TC = O(n) 28 | public static int[] Shuffle2(int[] nums, int n) 29 | { 30 | 31 | if (nums == null || nums.Length == 0) 32 | return nums; 33 | 34 | int[] res = new int[2 * n]; 35 | 36 | for (int i = 0; i < n; i++) 37 | { 38 | res[2 * i] = nums[i]; 39 | res[2 * i + 1] = nums[n + i]; 40 | } 41 | 42 | return res; 43 | } 44 | 45 | //2 pointers 46 | // every iteration it set new int in result 47 | // isFirst is a helper to decide on index 48 | public int[] Shuffle3(int[] nums, int n) 49 | { 50 | int[] result = new int[nums.Length]; 51 | int index = 0; 52 | bool isFirst = true; 53 | int i = 0, j = n; 54 | 55 | while (i < n || j < nums.Length) 56 | { 57 | if (isFirst) 58 | { 59 | result[index++] = nums[i++]; 60 | } 61 | else 62 | { 63 | result[index++] = nums[j++]; 64 | } 65 | 66 | isFirst = !isFirst; 67 | } 68 | 69 | return result; 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /Algorith_A_Day/Backtracking/Letter_Combinations_of_P_Number_LC_17_M.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Algorithm_A_Day.Backtracking 6 | { 7 | public class Letter_Combinations_of_P_Number_LC_17_M 8 | { 9 | 10 | /// 11 | /// See the Backtracking file 12 | /// 13 | 14 | public static IList LetterCombinations(string digits) 15 | { 16 | var result = new List(); 17 | if (digits.Length == 0 || digits == null) return result; 18 | 19 | var mapping = new string[] 20 | { 21 | "0", 22 | "1", 23 | "abc", 24 | "def", 25 | "ghi", 26 | "jkl", 27 | "mno", 28 | "pqrs", 29 | "tuv", 30 | "wxyz", 31 | }; 32 | 33 | LetterCombinationsRecursive(result, digits, "", 0, mapping); 34 | 35 | return result; 36 | 37 | } 38 | 39 | private static void LetterCombinationsRecursive(List result, string digits, 40 | string current, int index, string[] mapping) 41 | { 42 | //base case 43 | if(index == digits.Length) 44 | { 45 | result.Add(current); 46 | return; 47 | } 48 | // -'0' makes it integer 49 | // for digits = "23" letters = abc or def 50 | string letters = mapping[digits[index] - '0']; 51 | 52 | for (int i = 0; i < letters.Length; i++) 53 | { 54 | LetterCombinationsRecursive(result, digits, current + letters[i], 55 | index + 1, mapping); 56 | } 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /Algorith_A_Day/Basics/CollatzConjecture.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Algorithm_A_Day.Basics 6 | { 7 | public class CollatzConjecture 8 | { 9 | public static int Collatz(int n) 10 | { 11 | if(n == 1) { return 0; } 12 | else if(n % 2 == 0) 13 | { 14 | return 1 + Collatz(n / 2); 15 | } 16 | else 17 | { 18 | return 1 + Collatz(3 * n + 1); 19 | } 20 | } 21 | 22 | //c(5) 23 | // 1 + c(15 + 1) c16 24 | // 1 + c(16 /2) c8 25 | // 1 + c(8 / 2) c4 26 | // 1 + c(4 /2) c2 27 | // 1 + c(2 / 2) c1 28 | // c(1) = 0 base case 29 | 30 | public static int CollatzIterativly(int n) 31 | { 32 | if (n == 1) { return 0; } 33 | int counter = 0; 34 | while(n > 1) 35 | { 36 | if(n % 2 == 0) 37 | { 38 | counter++; 39 | n = n / 2; 40 | } 41 | else 42 | { 43 | counter++; 44 | n = n * 3 + 1; 45 | } 46 | } 47 | return counter; 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Algorith_A_Day/Basics/Factorial.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Algorithm_A_Day.Basics 6 | { 7 | class Factorial 8 | { 9 | public static int NtFactorial(int nummber) 10 | { 11 | if (nummber == 0) return 1; 12 | if (nummber < 0) throw new ArgumentException("Negative nummber are not allowed!"); 13 | 14 | int facNumber = 1; 15 | 16 | for (int i = 1; i <= nummber; i++) 17 | { 18 | facNumber *= i; 19 | } 20 | return facNumber; 21 | } 22 | 23 | public static int FactorialRecursive(int nummber) 24 | { 25 | if (nummber == 0) return 1; //THIS IS BASE CASE 26 | if (nummber < 0) throw new ArgumentException("Negative nummber are not allowed!"); 27 | else 28 | { 29 | return nummber * FactorialRecursive(nummber - 1); 30 | } 31 | 32 | } 33 | 34 | 35 | //JS 36 | //function fac(a) 37 | //{ 38 | // if (a == 0) return 1; 39 | // else 40 | // { 41 | // return a * fac(a - 1); 42 | // } 43 | //} 44 | 45 | //console.log(fac(3)); 46 | 47 | // return 1; 48 | // return 1 * fac(0); -> 1 * 1 49 | // retrurn 2 * fac(1); -> 2 * 1 50 | // return 3 * fac(2); -> 3 * 2 51 | //5 1 * 2 * 3 * 4 * 5 52 | } 53 | } 54 | 55 | -------------------------------------------------------------------------------- /Algorith_A_Day/Basics/Palindrome.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Algorithm_A_Day.Basics 6 | { 7 | class Palindrome 8 | { 9 | /// 10 | /// Determines if a single word is a palindrome. 11 | /// 12 | /// a word 13 | /// true if palindrome, otherwise false 14 | static bool IsWordPalindrome(string word) 15 | { 16 | if (word == null) 17 | throw new ArgumentNullException(nameof(word)); 18 | 19 | if (word.Length < 2) 20 | return true; 21 | 22 | return IsPalidrome(0, word.Length - 1); 23 | 24 | bool IsPalidrome(int lo, int hi) 25 | { 26 | if (lo >= hi) 27 | return true; 28 | 29 | if (char.ToUpperInvariant(word[lo]) != 30 | char.ToUpperInvariant(word[hi])) 31 | return false; 32 | 33 | return IsPalidrome(lo + 1, hi - 1); 34 | } 35 | } 36 | 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Algorith_A_Day/BinarySearch/ExponentialSearch.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Algorithm_A_Day.BinarySearch 6 | { 7 | /// 8 | /// Goal: searching sorted unbounded/infinite arrays 9 | /// It's important mostly in huge arrays 10 | /// Exponectial search used BS in a way that it detrmines RANGE in which the target is. 11 | /// { 1, 2, 3, 4, 5, 6, 7, 15, 21, 50, 200, 400 } target 21 12 | /// the range will be 8/2 for left and 8 so { 5, 6, 7, 15, 21 } 13 | /// so binary search(arr, 4, 8, target) 14 | /// thanks to that its O(log(i)) where i is index of target in arr not like BS O(log(n)) 15 | /// 16 | class ExponentialSearch 17 | { 18 | public static int BSearch(int[] arr, int left, int right, int target) 19 | { 20 | int result = -1; 21 | 22 | while(left <= right) 23 | { 24 | int mid = left + (right - left) / 2; 25 | 26 | //base condition 27 | if (arr[mid] == target) return mid; 28 | // discard all elements in the left search space 29 | // including the mid element arr[mid +1, right] 30 | else if (arr[mid] <= target) left = mid + 1; 31 | // discard all elements in the right search space 32 | // including the mid element arr[left, mid -1] 33 | else right = mid - 1; 34 | } 35 | 36 | return result; 37 | } 38 | 39 | public static int ESearch(int[] arr, int target) 40 | { 41 | int bound = 1; 42 | 43 | //find the range where target lies 44 | while(bound < arr.Length && arr[bound] < target) 45 | { 46 | bound *= 2; 47 | } 48 | //call BS 49 | return BSearch(arr, bound / 2, Math.Min(bound, arr.Length -1 ), target); 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /Algorith_A_Day/BinarySearch/FindFirstOccurrence.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Algorithm_A_Day.BinarySearch 6 | { 7 | /// 8 | /// Goal here is to find first or last occurrence(index) of given number in arr 9 | /// 10 | /// 11 | /// mid = left + (right - left) / 2 it is safe to calculate mid like this with many rekords 12 | /// 13 | /// 14 | /// 15 | /// index not actual value 16 | public class FindFirstOccurrence 17 | { 18 | //{2, 2, 2, 2, 5, 6, 8, 10, 10, 10 } 19 | public int FindFirst(int[] arr, int target) 20 | { 21 | int left = 0; 22 | int right = arr.Length - 1; 23 | int firstOccurence = -1; 24 | 25 | while(left <= right) 26 | { 27 | int mid = (left + right) / 2; 28 | 29 | 30 | //check if el at mid index is equal to target 31 | //if yes we assign mid to firstOccurence 32 | if (arr[mid] == target) 33 | { 34 | firstOccurence = mid; 35 | right = mid - 1;//it is not rotated so right is nit important 36 | } 37 | else if (arr[mid] > target) right = mid - 1; 38 | else left = mid + 1; //(arr[mid] < target) 39 | } 40 | return firstOccurence; 41 | 42 | } 43 | 44 | public int FindLast(int[] arr, int target) 45 | { 46 | int left = 0; 47 | int right = arr.Length - 1; 48 | int result = -1; 49 | 50 | while(left <= right) 51 | { 52 | int mid = (left + right) / 2; 53 | 54 | if (arr[mid] == target) 55 | { 56 | result = mid; 57 | left = mid + 1; 58 | } 59 | else if (arr[mid] < target) left = mid + 1; 60 | else right = mid - 1; 61 | 62 | } 63 | return result; 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /Algorith_A_Day/BinarySearch/FindFloorOrCeil.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Algorithm_A_Day.BinarySearch 6 | { 7 | /// 8 | /// Goal: find floor or ceil of a given number in sorted arr of integers. 9 | /// {1, 4, 6, 8, 9 } 10 | /// 0 ceiling = 1, floor -1 because it is not in arr 11 | /// 2 ceiling = 4, floor 1 12 | /// 5 ceiling = 6, floor 4 13 | /// 9 ceiling = 9, floor 9 14 | /// 10 ceiling = -1, floor 9 -1 because it is not in arr 15 | /// 16 | /// For ceiling it is the smallest int in arr but >= target 17 | /// For floor it is the largest int in arr but <= target 18 | /// 19 | /// https://www.techiedelight.com/find-floor-ceil-number-sorted-array/ 20 | /// 21 | public class FindFloorOrCeil 22 | { 23 | public int GetCeil(int[] arr, int target) 24 | { 25 | int result = -1; 26 | int left = 0; 27 | int right = arr.Length - 1; 28 | 29 | while (left <= right) 30 | { 31 | int mid = left + (right - left) / 2; 32 | 33 | if (arr[mid] == target) result = arr[mid]; 34 | 35 | if (arr[mid] < target) 36 | { 37 | left = mid + 1; 38 | } 39 | else// (arr[mid] > target) 40 | { 41 | result = arr[mid]; 42 | right = mid - 1; 43 | } 44 | 45 | } 46 | return result; 47 | } 48 | 49 | //{1, 4, 6, 8, 9 } 50 | public int GetFloor(int[] arr, int target) 51 | { 52 | int result = -1; 53 | int left = 0; 54 | int right = arr.Length - 1; 55 | 56 | while(left <= right) 57 | { 58 | int mid = left + (right - left) / 2; 59 | 60 | if (arr[mid] == target) result = arr[mid]; 61 | else if(arr[mid] > target) 62 | { 63 | right = mid - 1; 64 | } 65 | else 66 | { 67 | result = arr[mid]; 68 | left = mid + 1; 69 | } 70 | } 71 | return result; 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /Algorith_A_Day/BinarySearch/FindPeakElement.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Algorithm_A_Day.BinarySearch 6 | { 7 | /// 8 | /// Goal: Find a peak element of an array (not smaller than neighbours) 9 | /// peak is an el bigger than the next and prev (or first/last el respectively) 10 | /// arr can have multiple peaks we want any 11 | /// 12 | /// here we use idea similar to BS not exactly itself 13 | /// recursive solution time complexity is O(log(n)) 14 | /// 15 | public class FindPeakElement 16 | { 17 | //resursively 18 | public static int FindPeakRecur(int[] arr, int left, int right) 19 | { 20 | int mid = left + (right - left) / 2; 21 | 22 | //base case we check if mid el is greater than neighbours 23 | //it takes care of special cases of last and first el 24 | //so if mid == 0 and next el is smaller, its peak 25 | //if mid ==len -1 and previous is smaller, its peak 26 | if((mid == 0 || arr[mid -1] <= arr[mid]) && 27 | (mid == arr.Length -1 || arr[mid + 1] <= arr[mid])) 28 | { 29 | return mid; 30 | } 31 | //if left el of mid is greater than mid 32 | //we seatch in left sub-array 33 | if (mid - 1 >= 0 && arr[mid - 1] > arr[mid]) 34 | return FindPeakRecur(arr, left, mid - 1); 35 | 36 | //if right el of mid is greater than mid 37 | //we seatch in right sub-array 38 | return FindPeakRecur(arr, mid + 1, right); 39 | 40 | } 41 | 42 | //interatively 43 | public static int FindPeakIter(int[] arr) 44 | { 45 | int left = 0; 46 | int right = arr.Length - 1; 47 | int result = -1; 48 | 49 | while(left <= right) 50 | { 51 | int mid = left + (right - left) / 2; 52 | if ((mid == 0 || arr[mid - 1] <= arr[mid]) && 53 | (mid == arr.Length - 1 || arr[mid + 1] <= arr[mid])) 54 | { 55 | result = mid; 56 | return result; 57 | } 58 | 59 | if(arr[mid -1] > arr[mid] && mid -1 >= 0) 60 | { 61 | right = mid - 1; 62 | } 63 | else 64 | { 65 | left = mid + 1; 66 | } 67 | 68 | } 69 | return result; 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /Algorith_A_Day/BinarySearch/FindTargetNumber.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Reflection.Metadata.Ecma335; 4 | using System.Text; 5 | 6 | namespace Algorithm_A_Day.BinarySearch 7 | { /// 8 | /// Goal is to find int target in rotated sorted array 9 | /// Most important here is to understand there is a pivot element 10 | /// 1.it divides arr in 2 sorted halfs 2. is always less than next and prev el to it. 11 | /// Firstly we need to check which part is sorted. 12 | /// Then check if target is in range of the sorted part 13 | /// if not do the same again for the opposite side with changed start and end of the array 14 | /// 15 | class FindTargetNumber 16 | { 17 | public int FindNumber(int[] arr, int target) 18 | { 19 | int left = 0; 20 | int right = arr.Length - 1; 21 | 22 | while (left <= right) 23 | { 24 | int mid = (left + right) / 2; 25 | 26 | //if el at mid is targer return mid index 27 | if (arr[mid] == target) return mid; 28 | 29 | //if right half [mid..right] is sorted and mid is not 30 | //the target {14, 18, 21, 3, 6, 8, 9, 12} 3 < 12 31 | 32 | if (arr[mid] <= arr[right]) 33 | { 34 | //compare target with arr[mid] and arr[right] 35 | //to find if it lies in arr[mid..right] 36 | if (target > arr[mid] && target <= arr[right]) 37 | left = mid + 1; //searching in the right sorted half 38 | else 39 | right = mid - 1;//go search left in arr[left...mid-1] 40 | //it can be sorted/unsorted 41 | } 42 | 43 | //if left half [left..mid] is sorted and mid is not 44 | //the target {12, 14, 18, 21, 3, 6, 8, 9} 21 > 12 45 | 46 | else //(arr[mid] >= arr[right] 47 | { 48 | //compare target with arr[mid] and arr[left] 49 | //to find if it lies in arr[left..mid] 50 | if (target < arr[mid] && target >= arr[left]) 51 | right = mid - 1;//searching in the left sorted half 52 | else 53 | left = mid + 1;//go search right in [mid +1..right] 54 | //it can be sorted/unsorted 55 | } 56 | } 57 | return -1; 58 | } 59 | 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /Algorith_A_Day/BinarySearch/SearchInNearlySorted.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Algorithm_A_Day.BinarySearch 6 | { 7 | /// 8 | /// Goal: search for el in nearly sorted array(el is +- 1 from corect order) 9 | /// { 2,1,3,5,4,7,6,8,9 } target 5 index 3 10 | /// { 2,1,3,5,4,7,6,8,9 } target 10 index -1 11 | /// The idea here is to compare targer with arr[mid-1] and arr[mid +1] 12 | /// 13 | public class SearchInNearlySorted 14 | { 15 | public static int GetFromNS(int[] arr, int target) 16 | { 17 | int left = 0; 18 | int right = arr.Length - 1; 19 | 20 | while(left <= right) 21 | { 22 | int mid = left + (right - left) / 2; 23 | 24 | if (arr[mid] == target) return mid; 25 | else if (arr[mid - 1] == target && mid - 1 >= left) 26 | { 27 | return mid - 1; 28 | } 29 | else if (arr[mid + 1] == target && mid + 1 <= right) 30 | { 31 | return mid + 1; 32 | } 33 | //mid el and +- elements are not target so we reduce search space 34 | //target is bigger than arr[mid] so we search i right subarray 35 | //(mid + 2) cause we already checked arr[mid+1] 36 | else if (target > arr[mid]) 37 | { 38 | left = mid + 2; 39 | } 40 | //mid el and +- elements are not target so we reduce search space 41 | //target is smaller than arr[mid] so we search i left subarray 42 | //(mid - 2) cause we already checked arr[mid-1] 43 | else 44 | { 45 | right = mid - 2; 46 | } 47 | } 48 | 49 | return -1; 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /Algorith_A_Day/BinaryTree/BinarySearchTree.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace BST.Traversals 6 | { 7 | class BinarySearchTree 8 | { 9 | 10 | } 11 | public class Bnode 12 | { 13 | public int label; 14 | 15 | public Bnode left; 16 | public Bnode right; 17 | 18 | public Bnode(int data) 19 | { 20 | this.label = data; 21 | left = null; 22 | right = null; 23 | } 24 | 25 | public void AddNode(Bnode root) 26 | { 27 | if(root == null) 28 | { 29 | Console.WriteLine("Can't add null to the tree"); 30 | } 31 | else if(root.label == label) 32 | { 33 | Console.WriteLine("No duplicates!"); 34 | } 35 | else if (label < root.label) 36 | { 37 | //left 38 | if(root.left != null) 39 | { 40 | AddNode(root.left); 41 | } 42 | else 43 | { 44 | Console.WriteLine("Added" + label + "to the left of" + root.label); 45 | root.left = this; 46 | } 47 | } 48 | else if (label > root.label) 49 | { 50 | //right 51 | if(root.right != null) 52 | { 53 | AddNode(root.right); 54 | } 55 | else 56 | { 57 | Console.WriteLine("Added" + label + "to the right of" + root.label); 58 | root.right = this; 59 | } 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Algorith_A_Day/BinaryTree/LeavesOfBt.cs: -------------------------------------------------------------------------------- 1 | using Algorithm_A_Day.NodesModels; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Algorithm_A_Day.BinaryTree 7 | { 8 | public class LeavesOfBt 9 | { 10 | public static int counter = 0; 11 | public static int LeavesNodeCount(TreeNode root) 12 | { 13 | if (root != null) 14 | { 15 | if (root.left == null && root.right == null) counter++; 16 | 17 | if (root.left != null) 18 | { 19 | LeavesNodeCount(root.left); 20 | } 21 | if (root.right != null) 22 | { 23 | LeavesNodeCount(root.right); 24 | } 25 | } 26 | return counter; 27 | } 28 | 29 | 30 | //ITERATIVELY 31 | public static int LeavesNodeCountIter(TreeNode root) 32 | { 33 | int counter = 0; 34 | if (root == null) return counter; 35 | 36 | var stack = new Stack(); 37 | stack.Push(root); 38 | 39 | while (stack.Count > 0) 40 | { 41 | var current = stack.Pop(); 42 | if (current.left == null && current.right == null) counter++; 43 | 44 | if (current.right != null) 45 | { 46 | stack.Push(current.right); 47 | } 48 | 49 | if (current.left != null) 50 | { 51 | stack.Push(current.left); 52 | } 53 | } 54 | return counter; 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /Algorith_A_Day/BinaryTree/TreeNode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace BST.Traversals 6 | { 7 | public class TreeNode 8 | { 9 | public int val; 10 | public TreeNode left; 11 | public TreeNode right; 12 | public TreeNode(int val = 0, TreeNode left = null, TreeNode right = null) 13 | { 14 | this.val = val; 15 | this.left = left; 16 | this.right = right; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Algorith_A_Day/Clash_of_Code/Ip_Address.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Algorithm_A_Day.Clash_of_Code 8 | { 9 | // descriptions of tasks in yt video 10 | // https://www.youtube.com/watch?v=Aoy2MRvYK2A&t=146s 11 | public class Ip_Address 12 | { 13 | public int GetPort(string ip) 14 | { 15 | if (ip.Length < 1) return -1; 16 | int firstDigit = ip[0]; 17 | double summ = 0; 18 | 19 | foreach (char c in ip) 20 | { 21 | if (c != '.' && char.IsNumber(c) && char.IsDigit(c)) 22 | { 23 | summ += char.GetNumericValue(c); 24 | } 25 | } 26 | return (int)summ * firstDigit; 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Algorith_A_Day/DP/Climbing_Stairs_LC_70_E_DP.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Algorithm_A_Day.DP 8 | { 9 | // dp CAN be used to solve this problem but it is not necessary 10 | public class Climbing_Stairs_LC_70_E_DP 11 | 12 | { 13 | /// 14 | /// the idea here is we know result for 2 first steps 15 | /// so each step we calculte next which we use in next iteration XDDD 16 | /// 17 | 18 | public int ClimbStairs(int n) 19 | { 20 | if (n < 0) return 0; 21 | if (n == 1 || n == 0) return 1; 22 | 23 | int[] result = new int[n + 1]; 24 | 25 | result[0] = 1; 26 | result[1] = 1; 27 | 28 | for (int i = 2; i <= n; i++) 29 | { 30 | result[i] = result[i - 1] + result[i - 2]; 31 | } 32 | 33 | return result[n]; 34 | 35 | } 36 | 37 | public int ClimbStairs2(int n) 38 | { 39 | if (n == 0) return 0; 40 | if (n == 1) return 1; 41 | if (n == 2) return 2; 42 | 43 | var prePre = 1; 44 | var pre = 2; 45 | 46 | for (int i = 2; i < n; i++) 47 | { 48 | var cur = prePre + pre; 49 | prePre = pre; 50 | pre = cur; 51 | } 52 | 53 | return pre; 54 | } 55 | 56 | // recursion 57 | // todo: good recursion 58 | public int ClimbStairs3(int n) 59 | { 60 | Dictionary mem = new Dictionary(); 61 | mem.Add(0, 0); 62 | mem.Add(1, 1); 63 | mem.Add(2, 2); 64 | return ClimbStairs(n, mem); 65 | } 66 | private int ClimbStairs(int n, Dictionary mem) 67 | { 68 | if (mem.ContainsKey(n)) return mem[n]; 69 | var result = ClimbStairs(n - 1, mem) + ClimbStairs(n - 2, mem); 70 | mem.Add(n, result); 71 | return result; 72 | } 73 | 74 | 75 | //JS 76 | //var climbStairs = function(n) { 77 | // if (n< 0) return 0; 78 | 79 | // result = []; 80 | 81 | // result[0] = 1; 82 | // result[1] = 1; 83 | 84 | // for (i = 2; i <= n; i++) 85 | // { 86 | // result[i] = result[i - 1] + result[i - 2]; 87 | // } 88 | 89 | // return result[n]; 90 | //}; 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /Algorith_A_Day/DP/Delete_Operation_for_Two_Strings_LC_583.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Algorithm_A_Day.DP 6 | { 7 | /// 8 | /// Longest common subsequence problem 9 | /// 10 | public class Delete_Operation_for_Two_Strings_LC_583 11 | { 12 | //public static int MinDistance(string word1, string word2) 13 | //{ 14 | 15 | //} 16 | 17 | 18 | 19 | // Pramp similar question 20 | public static int DeletionDistance(string str1, string str2) 21 | { 22 | int str1Len = str1.Length; 23 | int str2Len = str2.Length; 24 | 25 | var memo = new int[str1Len + 1, str2Len + 1]; 26 | 27 | for (int i = 0; i <= str1Len; i++) 28 | { 29 | for (int j = 0; j <= str2Len; j++) 30 | { 31 | if (i == 0) 32 | { 33 | memo[i, j] = j; 34 | } 35 | else if (j == 0) 36 | { 37 | memo[i, j] = i; 38 | } 39 | else if (str1[i - 1] == str2[j - 1]) 40 | { 41 | memo[i, j] = memo[i - 1, j - 1]; 42 | } 43 | else 44 | { 45 | memo[i, j] = 1 + Math.Min(memo[i - 1, j], memo[i, j - 1]); 46 | } 47 | } 48 | } 49 | return memo[str1Len, str2Len]; 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /Algorith_A_Day/DesignOnes/Design_Ordered_Stream_LC_1656_E.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Algorithm_A_Day.DesignOnes 8 | { 9 | public class Design_Ordered_Stream_LC_1656_E 10 | { 11 | private string[] result; 12 | private int index = 1; 13 | 14 | public Design_Ordered_Stream_LC_1656_E(int n) 15 | { 16 | result = new string[n + 1]; 17 | index = 1; 18 | } 19 | 20 | public IList Insert(int id, string value) 21 | { 22 | var res = new List(); 23 | var current = id; 24 | result[current] = value; 25 | 26 | if (index == id) 27 | { 28 | for (; current < result.Length; current++) 29 | { 30 | if (result[current] != null) 31 | { 32 | res.Add(result[current]); 33 | } 34 | else break; 35 | } 36 | index = current; 37 | } 38 | return res; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Algorith_A_Day/EASY_WORTH_RECALLING.txt: -------------------------------------------------------------------------------- 1 | Plus_One_66_LC_E 2 | Palindrome_Number_9 3 | Roman_to_Integer_LC_13 4 | Integer_to_Roman_LC_12 5 | Maximum_Subarray_LC_53_E Kadane;s Algorithm 6 | Jewels_and_Stones_LC_771_E;Climbing_Stairs_70 eazy DP problems 7 | 67. Add Binary binary adding 8 | 9 | Richest_Customer_Wealth_LC_1672_E goood js reduce examples 10 | 11 | Majority_Element_LC_169_E "Baylor Moore" majority vote algrithm -------------------------------------------------------------------------------- /Algorith_A_Day/Extensions/Extension Methods.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace Algorithm_A_Day.Extensions 7 | { 8 | public static class Extension_Methods 9 | { 10 | public static TValue GetValueOrDefault 11 | (this IDictionary dictionary, 12 | TKey key, 13 | TValue defaultValue) 14 | { 15 | TValue value; 16 | return dictionary.TryGetValue(key, out value) ? value : defaultValue; 17 | } 18 | 19 | public static TValue GetValueOrDefault 20 | (this IDictionary dictionary, 21 | TKey key, 22 | Func defaultValueProvider) 23 | { 24 | TValue value; 25 | return dictionary.TryGetValue(key, out value) ? value 26 | : defaultValueProvider(); 27 | } 28 | public static TValue GetOrCreate(this IDictionary dict, TKey key) 29 | where TValue : new() 30 | { 31 | TValue val; 32 | 33 | if (!dict.TryGetValue(key, out val)) 34 | { 35 | val = new TValue(); 36 | dict.Add(key, val); 37 | } 38 | 39 | return val; 40 | } 41 | /// 42 | /// Conerts source to 2D array. 43 | /// 44 | /// 45 | /// The type of item that must exist in the source. 46 | /// 47 | /// 48 | /// The source to convert. 49 | /// 50 | /// 51 | /// Thrown if source is null. 52 | /// 53 | /// 54 | /// The 2D array of source items. 55 | /// 56 | public static T[,] To2DArray(this IList> source) 57 | { 58 | if (source == null) 59 | { 60 | throw new ArgumentNullException("source"); 61 | } 62 | 63 | int max = source.Select(l => l).Max(l => l.Count()); 64 | 65 | var result = new T[source.Count, max]; 66 | 67 | for (int i = 0; i < source.Count; i++) 68 | { 69 | for (int j = 0; j < source[i].Count(); j++) 70 | { 71 | result[i, j] = source[i][j]; 72 | } 73 | } 74 | 75 | return result; 76 | } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /Algorith_A_Day/MathRelated/Pramp/Root_Of_Number.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Algorithm_A_Day.MathRelated.Pramp 6 | { 7 | /// 8 | /// https://www.youtube.com/watch?v=S2VfJh8J0gc&t=2788s 9 | /// 10 | public class Root_Of_Number 11 | { 12 | public static double Root(double x, int n) 13 | { 14 | if (x == 0) return 0; 15 | 16 | double lowerBound = 0; 17 | double upperBound = Math.Max(1, x); 18 | double error = 0.001; 19 | double approxRoot = (lowerBound + upperBound) / 2; 20 | 21 | while(approxRoot - lowerBound >= error) 22 | { 23 | if(Math.Pow(approxRoot, n) > x) 24 | { 25 | upperBound = approxRoot; 26 | } 27 | else if(Math.Pow(approxRoot, n) < x) 28 | { 29 | lowerBound = approxRoot; 30 | } 31 | else 32 | { 33 | break; 34 | } 35 | 36 | approxRoot = (upperBound + lowerBound) / 2; 37 | } 38 | return approxRoot; 39 | 40 | } 41 | //9 / 2 = 4.5 4.5 * 4.5 20,25 > 9 3 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Algorith_A_Day/MathRelated/Sqrt(x)_LC_69.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Algorithm_A_Day.MathRelated 6 | { 7 | public class Sqrt_x__LC_69 8 | { 9 | //timelimit exceeded for some reason 10 | public static int MySqrt(int x) 11 | { 12 | double result = 0; 13 | 14 | double upperBound = x; 15 | double lowerBound = 0.0; 16 | 17 | while(lowerBound < upperBound) 18 | { 19 | var mid = lowerBound + (upperBound - lowerBound) / 2; 20 | var current = Math.Pow(mid, 2); 21 | if (current == mid) 22 | { 23 | result = mid; 24 | return (int) current; 25 | } 26 | 27 | if (current < x) 28 | { 29 | lowerBound = mid; 30 | } 31 | if (current > x) 32 | { 33 | upperBound = mid; 34 | } 35 | } 36 | return (int)result; 37 | } 38 | 39 | public static int MySqrt2(int x) 40 | { 41 | if (x == 0) return 0; 42 | 43 | long left = 0; 44 | long right = int.MaxValue / 2 + 1; 45 | 46 | while (left < right) 47 | { 48 | long mid = left + (right - left) / 2; 49 | long candidate = mid * mid; 50 | if (candidate == mid) 51 | { 52 | return (int)candidate; 53 | } 54 | else if (candidate > x) 55 | { 56 | right = mid; 57 | } 58 | else 59 | { 60 | left = mid + 1; 61 | } 62 | } 63 | 64 | return (int)left - 1; 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /Algorith_A_Day/Multidimensional Arrays/Ada King CodeChef.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Algorithm_A_Day.Multidimensional_Arrays 6 | { 7 | /// 8 | /// Goal: place a king and some obstacles on a chessboard in such a way 9 | /// that the number of distinct cells the king can reach is exactly K(input from the user here) 10 | /// Chessboard is 8X8. 11 | ///for //K = 5 12 | //........ 13 | //........ 14 | //........ 15 | //........ 16 | //........ 17 | //XXX..... 18 | //..XX.... 19 | //O..X.... 20 | /// 21 | public class Ada_King_CodeChef 22 | { 23 | public static string[][] GetFilledBoard() 24 | { 25 | Console.WriteLine("Enter number from 1-64:"); 26 | int input = int.Parse(Console.ReadLine()); 27 | if (input > 64 || input < 1) 28 | { 29 | throw new Exception("Wrong input"); 30 | } 31 | 32 | string[][] board = new string[8][]; 33 | for (int i = 0; i < board.Length; i++) 34 | { 35 | board[i] = new string[] { ".", ".", ".", ".", ".", ".", ".", "." }; 36 | } 37 | board[0][0] = "O"; 38 | int counter = 1; 39 | 40 | for (int i = 0; i < board.Length; i++) 41 | { 42 | for (int j = 0; j < board[i].Length; j++) 43 | { 44 | if (counter < input && board[i][j] != "O") 45 | { 46 | counter++; 47 | } 48 | else if (board[i][j] != "O") board[i][j] = "X"; 49 | Console.Write(board[i][j]); 50 | } 51 | Console.WriteLine(); 52 | } 53 | 54 | return board; 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /Algorith_A_Day/Multidimensional Arrays/Spiral_Matrix_II_59.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Algorithm_A_Day.Multidimensional_Arrays 6 | { 7 | public class Spiral_Matrix_II_59 8 | { 9 | public static int[][] GenerateMatrix(int n) 10 | { 11 | if (n < 0) throw new ArgumentException(); 12 | 13 | var result = new int[n][]; 14 | if (n == 0) return result; 15 | 16 | for (int i = 0; i < n; i++) 17 | { 18 | result[i] = new int[n]; 19 | } 20 | 21 | int currentColumn = 0; 22 | int currentRow = 0; 23 | int lastColumn = n - 1; 24 | int lastRow = n - 1; 25 | int currentNumber = 0; 26 | 27 | while (currentRow <= lastRow && currentColumn <= lastColumn) 28 | { 29 | for (int i = currentColumn; i <= lastColumn; i++) 30 | { 31 | result[currentRow][i] = currentNumber + 1; 32 | currentNumber++; 33 | } 34 | currentRow++; 35 | 36 | 37 | for (int i = currentRow; i <= lastRow; i++) 38 | { 39 | result[i][lastColumn] = currentNumber + 1; 40 | currentNumber++; 41 | } 42 | lastColumn--; 43 | 44 | if (currentRow <= lastRow) 45 | { 46 | for (int i = lastColumn; i >= currentColumn; i--) 47 | { 48 | result[lastRow][i] = currentNumber + 1; 49 | currentNumber++; 50 | } 51 | lastRow--; 52 | } 53 | 54 | if (currentColumn <= lastColumn) 55 | { 56 | for (int i = lastRow; i >= currentRow; i--) 57 | { 58 | result[i][currentColumn] = currentNumber + 1; 59 | currentNumber++; 60 | } 61 | currentColumn++; 62 | } 63 | } 64 | return result; 65 | 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /Algorith_A_Day/NodesModels/ListNode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Algorithm_A_Day.NodesModels 6 | { 7 | public class ListNode 8 | { 9 | public int val; 10 | public ListNode next; 11 | public ListNode(int x = 0, ListNode next = null) 12 | { 13 | this.val = x; 14 | this.next = next; 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Algorith_A_Day/NodesModels/Node.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Algorithm_A_Day.NodesModels 6 | { 7 | public class Node 8 | { 9 | public int val; 10 | public Node left; 11 | public Node right; 12 | public Node next; 13 | 14 | public Node() { } 15 | 16 | public Node(int _val) 17 | { 18 | val = _val; 19 | } 20 | 21 | public Node(int _val, Node _left, Node _right, Node _next = null) 22 | { 23 | val = _val; 24 | left = _left; 25 | right = _right; 26 | next = _next; 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Algorith_A_Day/NodesModels/TreeNode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Algorithm_A_Day.NodesModels 6 | { 7 | public class TreeNode 8 | { 9 | public int val; 10 | public TreeNode left; 11 | public TreeNode right; 12 | public bool isVisited; 13 | public TreeNode(int val = 0, TreeNode left = null, TreeNode right = null, bool isVisited = false) 14 | { 15 | this.val = val; 16 | this.left = left; 17 | this.right = right; 18 | this.isVisited = isVisited; 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Algorith_A_Day/Patterns/2Pointers/3Sum_Closest_LC_16.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Algorithm_A_Day.Patterns._2Pointers 6 | { 7 | public class _3Sum_Closest_LC_16 8 | { 9 | public static int ThreeSumClosest(int[] nums, int target) 10 | { 11 | int closestGlobal = int.MaxValue; 12 | int globalSum = 0; 13 | 14 | Array.Sort(nums); 15 | for (int i = 0; i < nums.Length; i++) 16 | { 17 | int left = i + 1; 18 | int right = nums.Length - 1; 19 | 20 | while (left < right) 21 | { 22 | int currentSum = nums[i] + nums[left] + nums[right]; 23 | var closestLocal = Math.Abs(currentSum - target); 24 | 25 | if (currentSum == target) return target; 26 | else if (currentSum > target) 27 | { 28 | right--; 29 | } 30 | else 31 | { 32 | left++; 33 | } 34 | 35 | if(closestGlobal > closestLocal) 36 | { 37 | closestGlobal = closestLocal; 38 | globalSum = currentSum; 39 | } 40 | } 41 | } 42 | 43 | return globalSum; 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Algorith_A_Day/Patterns/2Pointers/Intersection_of_Two_Arrays_II_LC_350.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Algorithm_A_Day.Patterns._2Pointers 6 | { 7 | public class Intersection_of_Two_Arrays_II_LC_350 8 | { 9 | public static int[] Intersect(int[] nums1, int[] nums2) 10 | { 11 | var result = new List(); 12 | Array.Sort(nums1); 13 | Array.Sort(nums2); 14 | 15 | int p1 = 0, p2 = 0; 16 | 17 | while (p1 < nums1.Length && p2 < nums2.Length) 18 | { 19 | if (nums1[p1] < nums2[p2]) 20 | { 21 | p1++; 22 | } 23 | else if (nums1[p1] > nums2[p2]) 24 | { 25 | p2++; 26 | } 27 | else 28 | { 29 | result.Add(nums1[p1]); 30 | p1++; 31 | p2++; 32 | } 33 | 34 | } 35 | return result.ToArray(); 36 | } 37 | 38 | // with dictionary 39 | public static int[] Intersect2(int[] nums1, int[] nums2) 40 | { 41 | var numAndCount1 = new Dictionary(); 42 | 43 | foreach (var num in nums1) 44 | { 45 | if (!numAndCount1.ContainsKey(num)) numAndCount1[num] = 0; 46 | 47 | numAndCount1[num]++; 48 | } 49 | 50 | var result = new List(); 51 | 52 | foreach (var num in nums2) 53 | { 54 | if (numAndCount1.ContainsKey(num) && numAndCount1[num] > 0) 55 | { 56 | result.Add(num); 57 | 58 | numAndCount1[num]--; 59 | } 60 | } 61 | 62 | return result.ToArray(); 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /Algorith_A_Day/Patterns/2Pointers/RemoveElement LC - 27.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Algorithm_A_Day.Patterns._2Pointers 6 | { 7 | public class RemoveElement_LC___27 8 | { 9 | public static int RemoveElement(int[] nums, int val) 10 | { 11 | //int j = 0; 12 | //for (int i = 0; i < nums.Length; i++) 13 | //{ 14 | // if(nums[i] != val) 15 | // { 16 | // nums[j] = nums[i]; 17 | // j++; 18 | // } 19 | //} 20 | //return j; 21 | 22 | 23 | //we swap val with last element and check again for val and decrement right pointer 24 | // we check again for val and decrement if they r equal 25 | int i = 0; 26 | int n = nums.Length; 27 | while (i < n) 28 | { 29 | if (nums[i] == val) 30 | { 31 | nums[i] = nums[n - 1]; 32 | // reduce array size by one 33 | n--; 34 | } 35 | else 36 | { 37 | i++; 38 | } 39 | } 40 | return n; 41 | } 42 | 43 | //it shows right results but doesnt pass tests 44 | public static int RemoveElement2(int[] nums, int val) 45 | { 46 | int j = nums.Length - 1; 47 | int i = 0; 48 | if (nums.Length == 0) return -1; 49 | 50 | 51 | while (i < j) 52 | { 53 | while (nums[j] == val) 54 | { 55 | j--; 56 | } 57 | if (nums[i] != val) 58 | { 59 | i++; 60 | } 61 | else 62 | { 63 | nums[i] = nums[j]; 64 | nums[j] = val; 65 | j--; 66 | } 67 | } 68 | return nums.Length - (j + 1); 69 | } 70 | 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /Algorith_A_Day/Patterns/2Pointers/Remove_Duplicates_from_Sorted Array_LC_26.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Algorithm_A_Day.Patterns._2Pointers 6 | { 7 | public class Remove_Duplicates_from_Sorted_Array_LC_26 8 | { 9 | //for reason i can't see it doesn't pass the tests 10 | public static int RemoveDuplicates(int[] nums) 11 | //return new HashSet(nums).Count; 12 | { 13 | int left = 0, right = nums.Length - 1; 14 | int result = nums[right]; 15 | int farLeft = nums[left]; 16 | int farRight = nums[right]; 17 | int index = 0; 18 | 19 | while(farLeft <= farRight) 20 | { 21 | nums[index] = farLeft; 22 | farLeft++; 23 | index++; 24 | } 25 | return result; 26 | } 27 | 28 | /// 29 | /// Each iteration we compare it to saved variable(ind i) with variable (ind j) 30 | /// if they are no the same we increment i and swap 31 | /// if elemnts are in good order 1,2 -> i = 1 j = 1 so it swap 1 with 1 32 | /// 33 | /// 34 | /// 35 | public static int RemoveDuplicates2(int[] nums) 36 | { 37 | if (nums.Length == 0) return 0; 38 | int i = 0; 39 | for (int j = 1; j < nums.Length; j++) 40 | { 41 | if (nums[j] != nums[i]) 42 | { 43 | i++; 44 | nums[i] = nums[j]; 45 | } 46 | } 47 | return i + 1; 48 | } 49 | } 50 | //[0, 0, 1, 1, 1, 2, 2, 3, 3, 4] 51 | } 52 | -------------------------------------------------------------------------------- /Algorith_A_Day/Patterns/2Pointers/Two Sum - LeetCode 1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Algorithm_A_Day.Patterns._2Pointers 6 | { 7 | public class Two_Sum___LeetCode_1 8 | { 9 | 10 | //it works only for sorted arr which cannot be the case here 11 | public static int[] TwoSums(int target, int[] arr) 12 | { 13 | int[] result = new int[2]; 14 | int s = 0; 15 | int e = arr.Length - 1; 16 | 17 | 18 | 19 | while(s < e) 20 | { 21 | int currentSum = arr[s] + arr[e]; 22 | 23 | 24 | if (currentSum == target){ 25 | result[0] = s; 26 | result[1] = e; 27 | return result; 28 | } 29 | else if(currentSum < target) 30 | { 31 | s++; 32 | } 33 | else 34 | { 35 | e--; 36 | } 37 | } 38 | return new int[] { -1, -1 }; 39 | } 40 | //Input: nums = [2,7,11,15], target = 9 41 | // TryAdd - nice XDDD 42 | public static int[] TwoSums2(int target, int[] nums) 43 | { 44 | var visitedNums = new Dictionary(); 45 | for (int i = 0; i < nums.Length; i++) 46 | { 47 | int delta = target - nums[i]; 48 | if(visitedNums.ContainsKey(delta)) 49 | { 50 | return new[] { visitedNums[delta], i }; 51 | } 52 | visitedNums.TryAdd(nums[i], i); 53 | } 54 | 55 | return new int[] { -1, -1 }; 56 | } 57 | 58 | 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /Algorith_A_Day/Patterns/BFS/Average_of_Levels_in_Binary_Tree_LC_637.cs: -------------------------------------------------------------------------------- 1 | using Algorithm_A_Day.NodesModels; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Algorithm_A_Day.Patterns.BFS 7 | { 8 | public class Average_of_Levels_in_Binary_Tree_LC_637 9 | { 10 | public static IList AverageOfLevels(TreeNode root) 11 | { 12 | var result = new List(); 13 | if (root == null) return result; 14 | 15 | var q = new Queue(); 16 | q.Enqueue(root); 17 | 18 | while (q.Count > 0) 19 | { 20 | double size = q.Count; 21 | double currentSum = 0; 22 | for (int i = 0; i < size; i++) 23 | { 24 | var current = q.Dequeue(); 25 | currentSum += current.val; 26 | if (current.left != null) 27 | { 28 | q.Enqueue(current.left); 29 | } 30 | if (current.right != null) 31 | { 32 | q.Enqueue(current.right); 33 | } 34 | } 35 | double avr = currentSum / size; 36 | result.Add(avr); 37 | } 38 | return result; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Algorith_A_Day/Patterns/BFS/Level Order_Traversal.cs: -------------------------------------------------------------------------------- 1 | using Algorithm_A_Day.NodesModels; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Algorithm_A_Day.Patterns.BFS 7 | { 8 | public class Level_Order_Traversal 9 | { 10 | //iterative solution 11 | public static IList> LevelOrder(TreeNode root) 12 | { 13 | var result = new List>(); 14 | if (root == null) return result; 15 | 16 | var q = new Queue(); 17 | q.Enqueue(root); 18 | 19 | while (q.Count > 0) 20 | { 21 | int size = q.Count; 22 | var newList = new List(); 23 | 24 | for (int i = 0; i < size; i++)// every time queue has diffrent size 25 | { 26 | var curr = q.Dequeue(); 27 | newList.Add(curr.val); 28 | 29 | if (curr.left != null) 30 | { 31 | q.Enqueue(curr.left); 32 | } 33 | 34 | if (curr.right != null) 35 | { 36 | q.Enqueue(curr.right); 37 | } 38 | } 39 | result.Add(newList); 40 | 41 | } 42 | return result; 43 | } 44 | 45 | // recursive solution 46 | public static IList> LevelOrderRecur(TreeNode root) 47 | { 48 | IList> list = new List>(); 49 | TreeLevel(root, list, 0); 50 | return list; 51 | } 52 | public static void TreeLevel(TreeNode root, IList> list, int level) 53 | { 54 | if (root != null) 55 | { 56 | if (list.Count == level) 57 | list.Add(new List()); 58 | list[level].Add(root.val); 59 | TreeLevel(root.left, list, level + 1); 60 | TreeLevel(root.right, list, level + 1); 61 | } 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /Algorith_A_Day/Patterns/BFS/Level Order_Traversal_ 2.cs: -------------------------------------------------------------------------------- 1 | using Algorithm_A_Day.NodesModels; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Algorithm_A_Day.Patterns.BFS 7 | { 8 | /// 9 | /// The algorithm is the same as Classic Level Order Traversal but we need to reverse the the list at the end or 10 | /// we can insert every new sublist at the beginning of the main list with list.Insert(0, Sublist) where 0 is the index 11 | /// 12 | public class Level_Order_Traversal__2 13 | { 14 | public static IList> LevelOrderTraversal(TreeNode root) 15 | { 16 | if (root == null) return null; 17 | 18 | var result = new List>(); 19 | 20 | var q = new Queue(); 21 | q.Enqueue(root); 22 | 23 | while (q.Count > 0) 24 | { 25 | int size = q.Count; 26 | var newList = new List(); 27 | 28 | for (int i = 0; i < size; i++) 29 | { 30 | var curr = q.Dequeue(); 31 | newList.Add(curr.val); 32 | 33 | if (curr.left != null) 34 | { 35 | q.Enqueue(curr.left); 36 | } 37 | 38 | if (curr.right != null) 39 | { 40 | q.Enqueue(curr.right); 41 | } 42 | } 43 | result.Add(newList); //result.Insert(0, newList); 44 | 45 | } 46 | result.Reverse(); 47 | return result; 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Algorith_A_Day/Patterns/CyclicSort/Missing_Number_LC_268.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Algorithm_A_Day.Patterns.CyclicSort 6 | { 7 | public class Missing_Number_LC_268 8 | { 9 | public static int MissingNumber(int[] nums) 10 | { 11 | 12 | for (int i = 0; i < nums.Length; i++) 13 | { 14 | int current = nums[i]; //i =2 , current = 3; 15 | if (current == nums.Length) continue; 16 | if(current != i) 17 | { 18 | int temp = nums[current]; //4 19 | nums[current] = current; 20 | nums[i] = temp; 21 | i--; 22 | } 23 | } 24 | for (int j = 0; j < nums.Length; j++) 25 | { 26 | if (nums[j] != j) return j; 27 | } 28 | return nums.Length; 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Algorith_A_Day/Patterns/DFS/Path_Sum_LC-112.cs: -------------------------------------------------------------------------------- 1 | using Algorithm_A_Day.NodesModels; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Algorithm_A_Day.Patterns.DFS 7 | { 8 | public class Path_Sum_LC_112 9 | { 10 | public bool HasPathSum(TreeNode root, int sum) 11 | { 12 | if (root == null) return false; 13 | 14 | var s = new Stack(); 15 | s.Push(root); 16 | 17 | while(s.Count > 0) 18 | { 19 | var current = s.Pop(); 20 | 21 | if (current.left == null && 22 | current.right == null && current.val == sum) 23 | { 24 | return true; 25 | } 26 | 27 | if (current.right != null) 28 | { 29 | current.right.val += current.val; 30 | s.Push(current.right); 31 | } 32 | if (current.left != null) 33 | { 34 | current.left.val += current.val; 35 | s.Push(current.left); 36 | } 37 | } 38 | return false; 39 | } 40 | 41 | public static bool HasPathSumRecur(TreeNode root, int sum) 42 | { 43 | if (root == null) 44 | { 45 | return false; 46 | } 47 | else if (root != null && root.left == null && 48 | root.right == null && root.val == sum) 49 | { 50 | return true; 51 | } 52 | else 53 | { 54 | int localSum = sum - root.val; 55 | return HasPathSumRecur(root.left, localSum) || HasPathSumRecur(root.right, localSum); 56 | } 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /Algorith_A_Day/Patterns/FastAndSlowPointers/Middle_of_Linked_List_LC_876.cs: -------------------------------------------------------------------------------- 1 | using Algorithm_A_Day.NodesModels; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | using System.Text.RegularExpressions; 6 | 7 | namespace Algorithm_A_Day.Patterns.FastAndSlowPointers 8 | { 9 | public class Middle_of_Linked_List_LC_876 10 | { 11 | public ListNode MiddleNode(ListNode head) 12 | { 13 | if (head == null) return head; 14 | 15 | //here when fast pointer reaches null and move 2x faster than slow 16 | // means slow will be in the middle == middle of linked list 17 | var slow = head; 18 | var fast = head; 19 | while (fast != null && fast.next != null) 20 | { 21 | slow = slow.next; 22 | fast = fast.next.next; 23 | } 24 | return slow; 25 | 26 | //var slow = head; 27 | //var fast = head.next; 28 | 29 | //while (fast != null) 30 | //{ 31 | // slow = slow.next; 32 | 33 | // if (fast.next != null) 34 | // { 35 | // fast = fast.next.next; 36 | // } 37 | // else 38 | // { 39 | // fast = null; 40 | // } 41 | //} 42 | 43 | //return slow; 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Algorith_A_Day/Patterns/K-thLargestElement/Kth_Largest_Element.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace Algorithm_A_Day.Patterns.K_thLargestElement 7 | { 8 | public class Kth_Largest_Element 9 | { 10 | // naive solution n log(n) as it uses .net sort algo (insertion if n < 16 , or heap or quick sort) 11 | public int FindKthLargest(int[] nums, int k) 12 | { 13 | Array.Sort(nums); 14 | return nums[nums.Length - k]; 15 | } 16 | /// 17 | /// Goal here is to leave always k largest items in dictionary 18 | /// every iteration: 19 | /// -we add items to dictionary Key:number,Value: quantity 20 | /// - check if dictionary size is not bigger than k if yes : 21 | /// we take first element in dictionary and remove(or decrement) it 22 | /// 23 | //min heap solution with sorted dictionary 24 | public int FindKthLargest2(int[] nums, int k) 25 | { 26 | SortedDictionary minHeap = new SortedDictionary(); 27 | int heapSize = 0; 28 | 29 | foreach (int num in nums) 30 | { 31 | if (minHeap.ContainsKey(num)) 32 | { 33 | minHeap[num]++; 34 | } 35 | else 36 | { 37 | minHeap.Add(num, 1); 38 | } 39 | heapSize++; 40 | 41 | if (heapSize > k) 42 | { 43 | var min = minHeap.First(); 44 | if (min.Value == 1) minHeap.Remove(min.Key); 45 | else 46 | { 47 | minHeap[min.Key]--; 48 | } 49 | heapSize--; 50 | } 51 | } 52 | return minHeap.First().Key; 53 | } 54 | // TODO: merge when we revision of merge sort 55 | //public int FindKthLargest3(int[] nums, int k) 56 | //{ 57 | 58 | //} 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /Algorith_A_Day/Patterns/MergeIntervals/InsertInterval/InsertInterval_LC_57_M.js: -------------------------------------------------------------------------------- 1 |  var insert = function(intervals, newInterval) { 2 | // return list of list with newInterval 3 | if(intervals.length == 0) return [newInterval]; 4 | 5 | // insert new interval in correct location 6 | const output = []; 7 | let pushed = false; 8 | 9 | for(const i of intervals){ 10 | // check only first numbers as we gonna mergr them anyway 11 | if(!pushed && newInterval[0] < i[0]){ 12 | output.push(newInterval); 13 | pushed = true; 14 | } 15 | output.push(i); 16 | } 17 | 18 | //for input [[1,5]] , [2,7] expected is [1,7] so we need to: 19 | // if new interval is not pushed we need to push it here: 20 | if (!pushed) output.push(newInterval); 21 | 22 | 23 | // merge intervals along with push newInterval 24 | // this is the same as mergeintervals 56 25 | return mergeIntervals(output); 26 | }; 27 | 28 | var mergeIntervals = (intervals) => { 29 | //normallly it shoul be sorted but it is sorted in that case 30 | const output = []; 31 | 32 | let candidateInterval = intervals[0]; 33 | 34 | 35 | for (let i = 1; i < intervals.length; i++) 36 | { 37 | const currentInterval = intervals[i]; 38 | 39 | if (currentInterval[0] <= candidateInterval[1]) 40 | { 41 | candidateInterval[1] = Math.max(candidateInterval[1], currentInterval[1]); 42 | } 43 | else 44 | { 45 | output.push(candidateInterval); 46 | candidateInterval = currentInterval; 47 | } 48 | } 49 | 50 | 51 | output.push(candidateInterval); 52 | 53 | 54 | return output; 55 | }; -------------------------------------------------------------------------------- /Algorith_A_Day/Patterns/MergeIntervals/Merge_Intervals_LC_56.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace Algorithm_A_Day.Patterns.MergeIntervals 7 | { 8 | public class Merge_Intervals_LC_56 9 | { 10 | // it shows mutability of list in c# 11 | 12 | public static int[][] Merge(int[][] intervals) 13 | { 14 | //for 0 or 1 elements (intervals) 15 | if (intervals.Length <= 0) return intervals; 16 | // it just put input with smaller first value first 17 | Array.Sort(intervals, (x, y) => x[0].CompareTo(y[0])); 18 | //int[][] temp = intervals.OrderBy(a => a[0]).ToArray(); 19 | var tempList = new List(); 20 | 21 | int[] currentIterval = intervals[0]; 22 | tempList.Add(currentIterval); 23 | 24 | for (int i = 1; i < intervals.Length; i++) 25 | { 26 | var next = intervals[i]; 27 | var lastFromResult = tempList.Last(); 28 | if(next[0] <= lastFromResult[1]) 29 | { 30 | //So he's able to do that because ArrayList is mutable in Java.(same C# as it seems) 31 | //Whatever modification he performs on the current interval within the for loop 32 | //is also reflected inside the interval found in output_arr. 33 | //If he were to update the interval under a new variable assignment, 34 | //then the interval update wouldn't roll over to the interval found in output_arr. 35 | //This same reasoning is also applicable to Python. 36 | //more: https://www.youtube.com/watch?v=qKczfGUrFY4 37 | lastFromResult[1] = Math.Max(lastFromResult[1], next[1]); 38 | } 39 | else 40 | { 41 | tempList.Add(next); 42 | } 43 | 44 | } 45 | return tempList.ToArray(); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Algorith_A_Day/Patterns/ModifiedBinarySearch/Binary_Search_LC_704.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Algorithm_A_Day.Patterns.ModifiedBinarySearch 6 | { 7 | public class Binary_Search_LC_704 8 | { 9 | public static int Search(int[] nums, int target) 10 | { 11 | if (nums.Length == 0) return -1; 12 | if (nums.Length == 1) return 0; 13 | 14 | int left = 0; 15 | int right = nums.Length -1; 16 | // in case of int overflow 17 | int mid = left + (right - left) / 2; 18 | 19 | while(left <= right) 20 | { 21 | if (nums[mid] == target) return mid; 22 | else if(nums[mid] > target) 23 | { 24 | right = mid -1; 25 | } 26 | else 27 | { 28 | left = mid + 1; 29 | } 30 | mid = left + (right - left) / 2; 31 | } 32 | return -1; 33 | } 34 | 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Algorith_A_Day/Patterns/ReverseLinkedList/Reverse_Linked_List_II_LC_92.cs: -------------------------------------------------------------------------------- 1 | using Algorithm_A_Day.NodesModels; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Algorithm_A_Day.Patterns.ReverseLinkedList 7 | { 8 | public class Reverse_Linked_List_II_LC_92 9 | { 10 | public static ListNode ReverseBetween(ListNode head, int m, int n) 11 | { 12 | if (head == null) return null; 13 | 14 | var current = head; 15 | ListNode prev = null; 16 | 17 | 18 | 19 | while (m > 1) 20 | { 21 | prev = current; 22 | current = current.next; 23 | m--; 24 | n--; 25 | } 26 | ListNode prevDummy = prev; 27 | ListNode tail = current; 28 | 29 | while (n > 0) 30 | { 31 | var next = current.next; 32 | current.next = prev; 33 | prev = current; 34 | current = next; 35 | n--; 36 | 37 | } 38 | 39 | if (prevDummy != null) 40 | { 41 | prevDummy.next = prev; 42 | } 43 | else 44 | { 45 | head = prev; 46 | } 47 | //we set next of 2 to 5 here and it is reflected in the list... 48 | tail.next = current; 49 | 50 | return head; 51 | } 52 | } 53 | } -------------------------------------------------------------------------------- /Algorith_A_Day/Patterns/ReverseLinkedList/Reverse_Linked_List_LC_206.cs: -------------------------------------------------------------------------------- 1 | using Algorithm_A_Day.NodesModels; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Algorithm_A_Day.Patterns.ReverseLinkedList 7 | { 8 | public class Reverse_Linked_List_LC_206 9 | { 10 | //iteratively 11 | //TODO: why head is 1 at the end ????? 12 | public static ListNode ReverseList(ListNode head) 13 | { 14 | if (head == null) return head; 15 | 16 | var current = head; 17 | ListNode previous = null; 18 | 19 | while(current != null) 20 | { 21 | ListNode next = current.next; 22 | current.next = previous; 23 | previous = current; 24 | current = next; 25 | 26 | } 27 | return previous; 28 | } 29 | 30 | public static ListNode ReverseListRecur(ListNode head) 31 | { 32 | if (head == null) 33 | return null; 34 | 35 | var reversed = ReverseListRecur(head.next); 36 | if (reversed == null) 37 | return head; 38 | 39 | var curr = head.next; 40 | head.next = null; 41 | curr.next = head; 42 | 43 | return reversed; 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Algorith_A_Day/Patterns/Sliding Window/Longest_Substring_Without_Repeating_Characters_LC_3.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Algorithm_A_Day.Patterns.Sliding_Window 6 | { 7 | public class Longest_Substring_Without_Repeating_Characters_LC_3 8 | { 9 | public int LengthOfLongestSubstring(string s) 10 | { 11 | if (s.Length == 0) return 0; 12 | if (s.Length == 1) return 1; 13 | 14 | int result = int.MinValue; 15 | var dict = new Dictionary(); 16 | int start = 0; 17 | 18 | for (int i = 0; i < s.Length; i++) 19 | { 20 | if (dict.ContainsKey(s[i])) 21 | { 22 | start = Math.Max(dict[s[i]], start); 23 | } 24 | result = Math.Max(result, i - start + 1); 25 | dict[s[i]] = i + 1; 26 | } 27 | 28 | return result == int.MinValue ? 0 : result; 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Algorith_A_Day/Patterns/Sliding Window/Maximum Sum Subarray of Size K.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Algorithm_A_Day.Patterns.Sliding_Window 6 | { 7 | public class Maximum_Sum_Subarray_of_Size_K 8 | { 9 | /// 10 | /// Goal Given an array of positive numbers and a positive number ‘k’, 11 | /// find the maximum sum of any contiguous subarray of size ‘k. 12 | /// Input: [2, 1, 5, 1, 3, 2], k=3 13 | /// Output: 9 14 | /// Explanation: Subarray with maximum sum is [5, 1, 3]. 15 | /// 16 | public static int findMaxSumSubArray(int k, int[] arr) 17 | { 18 | int result = 0; 19 | int currentSum = 0; 20 | int start = 0; 21 | 22 | for (int i = 0; i < arr.Length ; i++) 23 | { 24 | //firstly it's sum k elements than add one and compare 25 | currentSum += arr[i]; 26 | 27 | //after k elements it compares sum and max current sum 28 | // then subrust very left element 29 | if(i >= k - 1) 30 | { 31 | result = Math.Max(result, currentSum); //if (currentSum > result) result = currentSum; 32 | currentSum -= arr[start]; 33 | start++; 34 | } 35 | } 36 | 37 | return result; 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Algorith_A_Day/Patterns/Sliding Window/Sliding Window.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Algorithm_A_Day.Patterns.Sliding_Window 6 | { 7 | public class Sliding_Window 8 | { 9 | /// 10 | /// Goal: Find the average of all contiguous subarrays of size ‘K’ in it. 11 | /// Array: [1, 3, 2, 6, -1, 4, 1, 8, 2], K=5 12 | /// For the first 5 numbers (subarray from index 0-4), the average is: (1+3+2+6-1)/5 => 2.2(1+3+2+6−1)/5=>2.2 13 | /// The average of next 5 numbers(subarray from index 1-5) is: (3+2+6-1+4)/5 => 2.8(3+2+6−1+4)/5=>2.8 14 | /// https://www.educative.io/courses/grokking-the-coding-interview/7D5NNZWQ8Wr 15 | /// 16 | 17 | // TC - O(N*K) where N is number in arr 18 | public static double[] GetAverageSubArraysSizeKNaive(int K, int[] arr) 19 | { 20 | var result = new double[arr.Length - K + 1]; 21 | 22 | //less or equal because it has to take el at index 4 so 5th el (len -K) 23 | for (int i = 0; i <= arr.Length - K; i++) 24 | { 25 | double currentSum = 0; 26 | for (int j = i; j < i + K ; j++) 27 | { 28 | currentSum += arr[j]; 29 | } 30 | result[i] = currentSum / K; 31 | } 32 | return result; 33 | } 34 | 35 | //here we get the sum of K elements and then substract from sum first element and add the next one (from loop index) 36 | // TC - O(N) 37 | public static double[] GetAverageSubArraysSizeK(int K, int[] arr) 38 | { 39 | var result = new double[arr.Length - K + 1]; 40 | double currentSum = 0.0; 41 | int windowStart = 0; 42 | 43 | for (int windowEnd = 0; windowEnd < arr.Length; windowEnd++) 44 | { 45 | currentSum += arr[windowEnd]; 46 | 47 | if(windowEnd >=K - 1) 48 | { 49 | result[windowStart] = currentSum / K; 50 | currentSum -= arr[windowStart]; 51 | windowStart++; 52 | } 53 | } 54 | return result; 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /Algorith_A_Day/RandomEasy/Build_Array_from_Permutation_LC_1920_E.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Algorithm_A_Day.RandomEasy 8 | { 9 | public class Build_Array_from_Permutation_LC_1920_E 10 | { 11 | public int[] BuildArray(int[] nums) 12 | { 13 | if (nums == null) return Array.Empty(); 14 | 15 | int[] result = new int[nums.Length]; 16 | 17 | for (int i = 0; i < nums.Length; i++) 18 | { 19 | int current = nums[i]; 20 | result[i] = nums[current]; 21 | } 22 | 23 | return result; 24 | } 25 | 26 | //using bit-shifting.... 27 | //In order to optimize the solution somewhat, and to meet the Follow-Up requirement for O(1) space complexity, 28 | //we can rely on bit-shifting, something which is possible due to the low values in nums. 29 | //https://leetcode.com/problems/build-array-from-permutation/discuss/1315480/Java-or-O(1)-Space-O(n)-Time 30 | public int[] BuildArray2(int[] nums) 31 | { 32 | int mask = 1023; // Decimal value of the binary number '1111111111' 33 | for (int i = 0; i < nums.Length; i++) 34 | nums[i] |= (nums[nums[i]] & mask) << 10; 35 | for (int i = 0; i < nums.Length; i++) 36 | nums[i] = nums[i] >> 10; 37 | return nums; 38 | } 39 | 40 | 41 | /* 42 | const buildArray=nums=>{ 43 | return nums.reduce((total,item,index)=>{ 44 | total.push(nums[nums[index]]) 45 | return total 46 | },[]) 47 | } 48 | 49 | */ 50 | 51 | /* 52 | const buildArray=nums=>{ 53 | let result=nums.map((item,index)=>nums[nums[index]]) 54 | return result 55 | } 56 | 57 | */ 58 | 59 | /* 60 | const buildArray=nums=>{ 61 | let result=[] 62 | nums.forEach((item,index)=>{ 63 | result[index]=nums[nums[index]] 64 | }) 65 | return result 66 | } 67 | */ 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /Algorith_A_Day/RandomEasy/Check_Equivalent_1662_LC_E.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Algorithm_A_Day.RandomEasy 6 | { 7 | public class Check_Equivalent_1662_LC_E 8 | { 9 | // simple brute force O(n) 10 | public bool ArrayStringsAreEqual(string[] word1, string[] word2) 11 | { 12 | string w1 = string.Empty; 13 | string w2 = string.Empty; 14 | foreach (string item in word1) 15 | { 16 | w1 += item; 17 | } 18 | 19 | foreach (string item in word2) 20 | { 21 | w2 += item; 22 | } 23 | 24 | return w1 == w2; 25 | } 26 | 27 | public bool ArrayStringsAreEqual2(string[] word1, string[] word2) 28 | { 29 | return string.Join("", word1) == string.Join("", word2); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Algorith_A_Day/RandomEasy/Contains_Duplicate_LC_217_E.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Algorithm_A_Day.RandomEasy 8 | { 9 | public class Contains_Duplicate_LC_217_E 10 | { 11 | public bool ContainsDuplicate(int[] nums) 12 | { 13 | if (nums.Length == 0 || nums.Length == 1) return false; 14 | 15 | HashSet visitedNumbers = new HashSet(); 16 | 17 | for (int i = 0; i < nums.Length; i++) 18 | { 19 | if (!visitedNumbers.Contains(nums[i])) 20 | { 21 | visitedNumbers.Add(nums[i]); 22 | } 23 | else 24 | { 25 | return true; 26 | } 27 | } 28 | 29 | return false; 30 | } 31 | 32 | public bool ContainsDuplicate2(int[] nums) 33 | { 34 | if (nums.Length == 0 || nums.Length == 1) return false; 35 | 36 | Array.Sort(nums); 37 | 38 | for (int i = 1; i < nums.Length; i++) 39 | { 40 | if (nums[i - 1] == nums[i]) return true; 41 | } 42 | 43 | return false; 44 | } 45 | 46 | //JS 47 | /* 48 | var containsDuplicate = function(nums) { 49 | if (nums.length == 0 || nums.length == 1) return false; 50 | 51 | let visitedNumbers = new Set(); 52 | 53 | for (let i = 0; i < nums.length; i++){ 54 | if (!visitedNumbers.has(nums[i])) 55 | { 56 | visitedNumbers.add(nums[i]); 57 | } 58 | else 59 | { 60 | return true; 61 | } 62 | } 63 | return false; 64 | }; 65 | 66 | XDDDDDDD 67 | var containsDuplicate = function(nums) { 68 | let s = new Set(nums) 69 | return s.size != nums.length 70 | }; 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | */ 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /Algorith_A_Day/RandomEasy/Convert_Sorted_Array_to_BST_LC_108_E.cs: -------------------------------------------------------------------------------- 1 | using Algorithm_A_Day.NodesModels; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace Algorithm_A_Day.RandomEasy 9 | { 10 | // The idea is to use start and end two indexes of the array to build a binary tree; 11 | // The root node should be middle index of the array, since balanced binary search tree, 12 | // make left subtree and right subtree same size or size difference minimum. 13 | public class Convert_Sorted_Array_to_BST_LC_108_E 14 | { 15 | public TreeNode SortedArrayToBST(int[] nums) 16 | { 17 | if (nums == null || nums.Length < 1) return null; 18 | 19 | return ConstructBSTfromArray(nums, 0, nums.Length - 1); 20 | } 21 | 22 | public TreeNode ConstructBSTfromArray(int[] nums, int left, int right) 23 | { 24 | if (left > right) return null; 25 | int mid = left + (right - left) / 2; 26 | TreeNode root = new TreeNode(nums[mid]); 27 | root.left = ConstructBSTfromArray(nums, left, mid - 1); 28 | root.right = ConstructBSTfromArray(nums, mid + 1, right); 29 | return root; 30 | } 31 | 32 | //JS 33 | //var sortedArrayToBST = function(nums) { 34 | // if (nums.length === 0) { 35 | // return null 36 | // } 37 | // const middle = Math.floor(nums.length / 2) 38 | // const root = new TreeNode(nums[middle]) 39 | // root.left = sortedArrayToBST(nums.slice(0, middle)) 40 | // root.right = sortedArrayToBST(nums.slice(middle + 1, nums.length)) 41 | 42 | // return root 43 | //} 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Algorith_A_Day/RandomEasy/Count_Matrix_LC_1351_E.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Algorithm_A_Day.RandomEasy 8 | { 9 | public class Count_Matrix_LC_1351_E 10 | { 11 | public int CountNegatives(int[][] grid) 12 | { 13 | if (grid == null || grid.Length == 0) return 0; 14 | 15 | int result = 0; 16 | 17 | for (int i = 0; i < grid.Length; i++) 18 | { 19 | for (int j = 0; j < grid[i].Length; j++) 20 | { 21 | if (grid[i][j] < 0) result++; 22 | } 23 | } 24 | 25 | 26 | 27 | return result; 28 | } 29 | 30 | //public int CountNegatives(int[][] grid) 31 | //{ 32 | // if (grid == null || grid.Length == 0) return 0; 33 | 34 | // int result = 0; 35 | 36 | // for (int i = 0; i < grid.Length; i++) 37 | // { 38 | // for (int j = grid[i].Length - 1; j >= 0; j--) 39 | // { 40 | // if (grid[i][j] < 0) result++; 41 | // else continue; 42 | // } 43 | // } 44 | 45 | // return result; 46 | //} 47 | 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Algorith_A_Day/RandomEasy/Decompress_Run_Length_Encoded_List_LC_1313_E.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Algorith_A_Day.RandomEasy 8 | { 9 | public class Decompress_Run_Length_Encoded_List_LC_1313_E 10 | { 11 | public int[] DecompressRLElist(int[] nums) 12 | { 13 | if (nums == null || nums.Length == 0 || nums.Length % 2 != 0) return new int[] { }; 14 | 15 | List result = new List(); 16 | 17 | for (int i = 0; i <= nums.Length - 2; i += 2) 18 | { 19 | for (int j = 0; j < nums[i]; j++) 20 | { 21 | result.Add(nums[i + 1]); 22 | } 23 | } 24 | return result.ToArray(); 25 | } 26 | } 27 | 28 | 29 | //JS 30 | //var decompressRLElist = function(nums) { 31 | //return nums.reduce((a, n, i) => !(i % 2) ?[...a, ...Array(n).fill(nums[i + 1])] : a,[]); 32 | //}; 33 | //const decompressRLElist = ns => 34 | //ns.reduce((acc, x, i) => 35 | // i % 2 36 | // ? acc.concat(Array(ns[i - 1]).fill(x)) 37 | // : acc 38 | // , [] 39 | //) 40 | 41 | // PIEKNE ROZWIAZANIE 42 | //var decompressRLElist = function(nums) { 43 | //var result = []; 44 | //for (var i = 0; i= 0 && address[i] == '.') 37 | { 38 | address = address.Substring(0, i) + "[.]" + address.Substring(i + 1); 39 | i += 2; 40 | } 41 | 42 | } 43 | 44 | return address; 45 | } 46 | 47 | public string DefangIPaddr3(string address) 48 | { 49 | //O(n) 50 | return address.Replace(".", @"[.]"); 51 | 52 | } 53 | 54 | /// 55 | /// return new array of numbers separated by . 56 | /// join with new sign 57 | /// 58 | /// 59 | /// 60 | public static string DefangIPaddr4(string address) 61 | { 62 | var x = address.Split("."); 63 | return string.Join("[.]", x); 64 | } 65 | 66 | 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /Algorith_A_Day/RandomEasy/Goal_Parser_Interpretation_LC_1678_E.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Algorithm_A_Day.RandomEasy 8 | { 9 | public class Goal_Parser_Interpretation_LC_1678_E 10 | { 11 | public string Interpret(string command) 12 | { 13 | if (command == null || command.Length == 0) return ""; 14 | 15 | string result = ""; 16 | int current = 0; 17 | while (current <= command.Length - 1) 18 | { 19 | if (command.Substring(current, 1) == "G") 20 | { 21 | result += "G"; 22 | current += 1; 23 | } 24 | else if (command.Substring(current, 2) == "()") 25 | { 26 | result += "o"; 27 | current += 2; 28 | } 29 | else 30 | { 31 | result += "al"; 32 | current += 4; 33 | } 34 | } 35 | 36 | return result; 37 | } 38 | 39 | // linq 40 | public string Interpret2(string command) => command.Replace("(al)", "al").Replace("()", "o"); 41 | 42 | // just nice 43 | public string Interpret3(string command) 44 | { 45 | string result = String.Empty; 46 | string currentString = String.Empty; 47 | foreach (char c in command) 48 | { 49 | currentString = currentString + c.ToString(); 50 | if (IsG(currentString)) 51 | { 52 | result = result + currentString; 53 | currentString = String.Empty; 54 | } 55 | else if (IsO(currentString)) 56 | { 57 | result = result + "o"; 58 | currentString = String.Empty; 59 | } 60 | else if (IsAL(currentString)) 61 | { 62 | result = result + "al"; 63 | currentString = String.Empty; 64 | } 65 | } 66 | return result; 67 | } 68 | private bool IsG(string value) 69 | { 70 | return (value == "G"); 71 | } 72 | 73 | private bool IsO(string value) 74 | { 75 | return (value == "()"); 76 | } 77 | 78 | private bool IsAL(string value) 79 | { 80 | return (value == "(al)"); 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /Algorith_A_Day/RandomEasy/Jewels_and_Stones_LC_771_E.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Algorithm_A_Day.RandomEasy 6 | { 7 | public class Jewels_and_Stones_LC_771_E 8 | { 9 | public int NumJewelsInStones(string J, string S) 10 | { 11 | if (J.Length == 0 || S.Length == 0) return 0; 12 | 13 | int result = 0; 14 | 15 | foreach (char j in J) 16 | { 17 | foreach (char s in S) 18 | { 19 | if (j == s) result++; 20 | } 21 | } 22 | return result; 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Algorith_A_Day/RandomEasy/Length_of_Last_Word_LC_58_E.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace Algorithm_A_Day.RandomEasy 7 | { 8 | public class Length_of_Last_Word_LC_58_E 9 | { 10 | public static int LengthOfLastWord(string s) 11 | { 12 | var arr = s.Split(" ", StringSplitOptions.RemoveEmptyEntries); 13 | if (arr.Length == 0 || string.IsNullOrEmpty(s)) return 0; 14 | 15 | return arr[arr.Length - 1].Length; 16 | 17 | } 18 | public int LengthOfLastWord2(string s) 19 | { 20 | var n = s.Length; 21 | 22 | if (n == 0) return 0; 23 | 24 | var length = 0; 25 | for (int i = n - 1; i >= 0; i--) 26 | { 27 | if (s[i] != ' ') 28 | { 29 | length++; 30 | } 31 | else 32 | { 33 | if (length != 0) 34 | { 35 | break; 36 | } 37 | } 38 | } 39 | 40 | return length; 41 | } 42 | 43 | //LINQ 44 | public int LengthOfLastWord3(string s) 45 | { 46 | return s.Trim().Split().LastOrDefault().Length; 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Algorith_A_Day/RandomEasy/Merge_Two_Sorted_L_Lists_LC_21.cs: -------------------------------------------------------------------------------- 1 | using Algorithm_A_Day.NodesModels; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Algorithm_A_Day.RandomEasy 7 | { 8 | public class Merge_Two_Sorted_L_Lists_LC_21 9 | { 10 | 11 | /// 12 | /// linked-list 13 | /// current.next = l1/l2 changes the result but current = current.l1/l2 doesn't 14 | /// reference more todo 15 | /// 16 | 17 | public static ListNode MergeTwoLists(ListNode l1, ListNode l2) 18 | { 19 | if (l1 == null) return l2; 20 | if (l2 == null) return l1; 21 | if (l2 == null && l1 == null) return null; 22 | 23 | ListNode result = new ListNode(0); 24 | ListNode current = result; 25 | 26 | while (l1 != null && l2 != null) 27 | { 28 | var r1 = Object.ReferenceEquals(result, current); 29 | var r2 = Object.ReferenceEquals(result, current.next); 30 | 31 | if (l1.val < l2.val) 32 | { 33 | current.next = l1; 34 | l1 = l1.next; 35 | } 36 | else 37 | { 38 | current.next = l2; 39 | l2 = l2.next; 40 | } 41 | 42 | current = current.next; 43 | } 44 | 45 | // l1 is lognger than l2 46 | if(l1 != null) 47 | { 48 | current.next = l1; 49 | l1 = l1.next; 50 | } 51 | 52 | // l2 is lognger than l1 53 | if (l2 != null) 54 | { 55 | current.next = l2; 56 | l2 = l2.next; 57 | } 58 | 59 | return result.next; 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /Algorith_A_Day/RandomEasy/Number_of_Good_Pairs_1512_LC_E.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Algorithm_A_Day.RandomEasy 6 | { 7 | public class Number_of_Good_Pairs_1512_LC_E 8 | { 9 | public int NumIdenticalPairs(int[] nums) 10 | { 11 | if (nums.Length < 2) return 0; 12 | 13 | int good_pairs = 0; 14 | 15 | for (int i = 0; i < nums.Length; i++) 16 | { 17 | for (int j = i + 1; j < nums.Length; j++) 18 | { 19 | if (nums[i] == nums[j] && i < j) good_pairs++; 20 | } 21 | } 22 | return good_pairs; 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Algorith_A_Day/RandomEasy/Number_of_Segments_in_a_String_LC_434_E.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Algorithm_A_Day.RandomEasy 8 | { 9 | public class Number_of_Segments_in_a_String_LC_434_E 10 | { 11 | public static int CountSegments(string s) 12 | { 13 | if (s == null || s.Length == 0) return 0; 14 | 15 | int result = 0; 16 | bool hasCharacter = false; 17 | 18 | for (int i = 1; i < s.Length; i++) 19 | { 20 | if (s[i].ToString() != " ") hasCharacter = true; 21 | if (s[i].ToString() == " " && s[i - 1].ToString() != " ") result++; 22 | } 23 | 24 | if (result == 0 && hasCharacter || (s.Length == 1 && s[0].ToString() != " ")) return 1; 25 | if (result > 0 && hasCharacter && s[s.Length - 1].ToString() != " ") return result + 1; 26 | 27 | int x = (int)'a'; 28 | var x1 = (int)'b'; 29 | 30 | 31 | return result; 32 | 33 | } 34 | 35 | //var x2 = (int)' ' === 32 36 | public static int CountSegments2(string s) 37 | { 38 | if (s == null || s == string.Empty) 39 | return 0; 40 | 41 | int count = 0; 42 | string trimmedString = s.Trim(); 43 | 44 | if (trimmedString == string.Empty) 45 | return 0; 46 | 47 | for (int index = 1; index <= trimmedString.Length - 1; index++) 48 | if ((int)trimmedString[index] == 32 && (int)trimmedString[index - 1] != 32) 49 | count++; 50 | 51 | return ++count; 52 | 53 | } 54 | 55 | //LINQ 56 | public static int CountSegments3(string s) 57 | { 58 | var word = s.Split(' ').ToList(); 59 | var removeSpace = word.RemoveAll(x => x == ""); 60 | 61 | return word.Count; 62 | } 63 | 64 | /* 65 | var countSegments = function (s) { 66 | let a = s.split(" "); 67 | let b = []; 68 | 69 | for (i = 0; i < a.length; i++) { 70 | if (a[i] !== "") { b.push(a[i]); } 71 | } 72 | 73 | return b.length; 74 | }; 75 | 76 | 77 | var countSegments = function(s) { 78 | if(!s) return 0; 79 | return s.split(' ').filter(val => {return val !== ''}).length; 80 | }; 81 | */ 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /Algorith_A_Day/RandomEasy/Number_of_Steps_to_Zero_LC_1342_E.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Algorithm_A_Day.RandomEasy 8 | { 9 | 10 | // check if number is an int https://stackoverflow.com/questions/2751593/how-to-determine-if-a-decimal-double-is-an-integer 11 | public class Number_of_Steps_to_Zero_LC_1342_E 12 | { 13 | public int NumberOfSteps(int num) 14 | { 15 | var x = num % 1 == 0; 16 | if (num <= 0 || !(num % 1 == 0)) return 0; 17 | 18 | int steps = 0; 19 | 20 | while (num > 0) 21 | { 22 | if (num % 2 == 0) 23 | { 24 | num /= 2; 25 | } 26 | else 27 | { 28 | num -= 1; 29 | } 30 | steps++; 31 | } 32 | return steps; 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Algorith_A_Day/RandomEasy/Palindrome_Number_9.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Algorithm_A_Day.RandomEasy 6 | { 7 | public class Palindrome_Number_9 8 | { 9 | //with string 10 | public static bool IsPalindrome(int x) 11 | { 12 | if (x < 0) return false; 13 | 14 | string s = x.ToString(); 15 | int left = 0; 16 | int right = s.Length - 1; 17 | 18 | while (left < right) 19 | { 20 | if (s[left] != s[right]) 21 | { 22 | return false; 23 | } 24 | left++; 25 | right--; 26 | } 27 | return true; 28 | } 29 | 30 | //without string 31 | public static bool IsPalindrome2(int x) 32 | { 33 | // Special cases: 34 | // when x < 0, x is not a palindrome. 35 | // Also if the last digit of the number is 0, in order to be a palindrome, 36 | // the first digit of the number also needs to be 0. 37 | // Only 0 satisfy this property. 38 | if (x < 0 || (x % 10 == 0 && x != 0)) 39 | { 40 | return false; 41 | } 42 | 43 | int revertedNumber = 0; 44 | while (x > revertedNumber) 45 | { 46 | revertedNumber = revertedNumber * 10 + x % 10; 47 | x /= 10; 48 | } 49 | 50 | // When the length is an odd number, we can get rid of the middle digit by revertedNumber/10 51 | // For example when the input is 12321, at the end of the while loop we get x = 12, revertedNumber = 123, 52 | // since the middle digit doesn't matter in palidrome(it will always equal to itself), we can simply get rid of it. 53 | return x == revertedNumber || x == revertedNumber / 10; 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /Algorith_A_Day/RandomEasy/Richest_Customer_Wealth_LC_1672_E.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Algorithm_A_Day.RandomEasy 8 | { 9 | public class Richest_Customer_Wealth_LC_1672_E 10 | { 11 | public int MaximumWealth(int[][] accounts) 12 | { 13 | if (accounts == null || accounts.Length == 0) return 0; 14 | 15 | int maxWealth = 0; 16 | 17 | for (int i = 0; i < accounts.GetLength(0); i++) 18 | { 19 | int currentSum = 0; 20 | for (int j = 0; j < accounts[i].Length; j++) 21 | { 22 | currentSum += accounts[i][j]; 23 | } 24 | maxWealth = Math.Max(maxWealth, currentSum); 25 | } 26 | return maxWealth; 27 | } 28 | public int MaximumWealth2(int[][] accounts) => accounts.Select(row => row.Sum()).Max(); 29 | 30 | } 31 | } 32 | 33 | // var maximumWealth = function(accounts) { 34 | // if(accounts == null || accounts.length == 0) return 0; 35 | 36 | // maxWealth = 0; 37 | 38 | // for(i = 0; i { 53 | // const result = val.reduce((acc, val) => acc + val, 0); 54 | // return Math.max(result, acc); 55 | // }, 0) 56 | //}; 57 | //let maximumWealth = A => Math.max(...A.map(row => _.sum(row))); 58 | //const sum = (array) => array.reduce((a, b) => a + b, 0); 59 | 60 | //const maximumWealth = (accounts) => accounts 61 | // .reduce((max, account) => Math.max(max, sum(account)), -Infinity); 62 | 63 | -------------------------------------------------------------------------------- /Algorith_A_Day/RandomEasy/Shuffle_String_LC_1528_E.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Algorithm_A_Day.RandomEasy 8 | { 9 | public class Shuffle_String_LC_1528_E 10 | { 11 | public string RestoreString(string s, int[] indices) 12 | { 13 | if (s == null || s.Length == 0) return string.Empty; 14 | if (indices == null || indices.Length == 0) return s; 15 | if (s.Length != indices.Length) return ""; 16 | 17 | char[] result = new char[indices.Length]; 18 | 19 | for (int i = 0; i < indices.Length; i++) 20 | { 21 | result[indices[i]] = s[i]; 22 | } 23 | 24 | //return new string(result); 25 | return string.Join("", result); 26 | } 27 | 28 | //LINQ 29 | public string RestoreString2(string s, int[] indices) 30 | { 31 | return String.Join("", s.ToArray().Select((x, idx) => new { Value = x, Index = idx }).OrderBy(x => indices[x.Index]).Select(x => x.Value).ToArray()); 32 | } 33 | 34 | public string RestoreString3(string s, int[] indices) 35 | { 36 | //SortesDictionary(); 37 | //dict.Add(indices[i],s[i]);. 38 | //Take a sorted dictionary. 39 | //return new string(dict.Values.ToArray()); 40 | SortedDictionary dict = new SortedDictionary(); 41 | for (int i = 0; i < indices.Length; i++) 42 | { 43 | dict.Add(indices[i], s[i]); 44 | } 45 | return new string(dict.Values.ToArray()); 46 | } 47 | 48 | //JS 49 | //var restoreString = function(s, indices) { 50 | //if (s == null || s.length == 0) return ""; 51 | //if (indices == null || indices.length == 0) return s; 52 | //if(s.length != indices.length) return ""; 53 | 54 | //result = []; 55 | 56 | //for(let i = 0; i{ 65 | // return { a, i: indices[i]}; 66 | // }).sort((a, b)=>a.i-b.i).map(({ a})=>a).join(''); 67 | //}; 68 | 69 | //const restoreString = (s, indices) => s.split('').map((c, i) => [c, indices[i]]).sort((a, b) => a[1] - b[1]).map(x => x[0]).join(''); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /Algorith_A_Day/RandomEasy/Subtract_Integer_1281_LC_E.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Algorithm_A_Day.RandomEasy 8 | { 9 | public class Subtract_Integer_1281_LC_E 10 | { 11 | public int SubtractProductAndSum(int n) 12 | { 13 | if (n <= 0) return - 1; 14 | 15 | int multi = 1; 16 | int addi = 0; 17 | 18 | foreach (char c in n.ToString()) 19 | { 20 | multi *= int.Parse(c.ToString()); 21 | addi += int.Parse(c.ToString()); 22 | } 23 | 24 | return multi - addi; 25 | } 26 | 27 | 28 | //suprisngly fast but SC not too good 29 | /* 30 | var subtractProductAndSum = function(n) { 31 | m = n.toString().split(''); 32 | 33 | addi = m.reduce((total, cur) => total + parseInt(cur), 0); 34 | multi = m.reduce((total, cur) => total * parseInt(cur), 1); 35 | 36 | return multi - addi; 37 | }; 38 | 39 | 40 | var subtractProductAndSum = function(n) { 41 | return [...String(n)].reduce((a,c) => a * Number(c)) - [...String(n)].reduce((a,c) => a + Number(c), 0) 42 | };???? 43 | 44 | var subtractProductAndSum = function(n) { 45 | let product = 1, sum = 0; 46 | while (n > 0) { 47 | let lastDigit = n % 10; 48 | product *= lastDigit; 49 | sum += lastDigit; 50 | n = Math.floor(n / 10); 51 | } 52 | return product - sum; 53 | }; 54 | */ 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /Algorith_A_Day/RandomEasy/Valid_Parentheses_LC_20_E.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Algorithm_A_Day.RandomEasy 6 | { 7 | public class Valid_Parentheses_LC_20_E 8 | { 9 | /// 10 | /// iterate over the string 11 | /// we either push each the opening paren. into stack 12 | /// or check if it closing one and the one of top of the stack is opposite 13 | /// if it is continue 14 | /// otherwise return false 15 | /// 16 | 17 | public static bool IsValid(string s) 18 | { 19 | 20 | if (s.Length % 2 != 0) return false; 21 | var stack = new Stack(); 22 | 23 | foreach (char c in s) 24 | { 25 | if (c == '{' || c == '(' || c == '[') 26 | { 27 | stack.Push(c); 28 | } 29 | else if (c == ']' && stack.Count > 0 && stack.Peek() == '[') 30 | { 31 | stack.Pop(); 32 | } 33 | else if (c == '}' && stack.Count > 0 && stack.Peek() == '{') 34 | { 35 | stack.Pop(); 36 | } 37 | else if (c == ')' && stack.Count > 0 && stack.Peek() == '(') 38 | { 39 | stack.Pop(); 40 | } 41 | else // "( [ } } ])" first closing is not on the top of the stack 42 | { 43 | return false; 44 | } 45 | } 46 | 47 | return !(stack.Count > 0); 48 | } 49 | 50 | // stack with dictionary 51 | public bool IsValid2(string s) 52 | { 53 | if (s == null || s == string.Empty) 54 | return true; 55 | 56 | Dictionary dict = new Dictionary(); 57 | Stack stack = new Stack(); 58 | 59 | dict.Add(')', '('); 60 | dict.Add('}', '{'); 61 | dict.Add(']', '['); 62 | 63 | foreach (var c in s) 64 | if (c == ')' || c == '}' || c == ']') 65 | { 66 | if (stack.Count > 0 && stack.Peek() == dict[c]) 67 | stack.Pop(); 68 | else 69 | return false; 70 | } 71 | else 72 | stack.Push(c); 73 | 74 | return stack.Count == 0; 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /Algorith_A_Day/RandomMedium/Sum_ Array_1685_LC_M.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Algorithm_A_Day.RandomMedium 8 | { 9 | public class Sum__Array_1685_LC_M 10 | { 11 | 12 | /// 13 | /// Brute force - time limit exceeded 14 | /// 15 | public int[] GetSumAbsoluteDifferences(int[] nums) 16 | { 17 | if (nums == null || nums.Length == 0) return Array.Empty(); 18 | int[] result = new int[nums.Length]; 19 | if (nums == null || nums.Length == 0) return result; 20 | 21 | for (int i = 0; i < nums.Length; i++) 22 | { 23 | int temp = 0; 24 | 25 | for (int j = 0; j < nums.Length; j++) 26 | { 27 | temp += (Math.Max(nums[i], nums[j]) - Math.Min(nums[i], nums[j])); 28 | } 29 | result[i] = temp; 30 | } 31 | 32 | return result; 33 | } 34 | 35 | public int[] GetSumAbsoluteDifferences2(int[] nums) 36 | { 37 | int[] prefixSum = new int[nums.Length + 1]; 38 | 39 | for (int i = 0; i < nums.Length; i++) 40 | { 41 | prefixSum[i + 1] = prefixSum[i] + nums[i]; 42 | } 43 | 44 | int[] result = new int[nums.Length]; 45 | 46 | for (int i = 0; i < nums.Length; i++) 47 | { 48 | int right = (prefixSum[nums.Length] - prefixSum[i + 1]) - nums[i] * (nums.Length - i - 1); 49 | int left = 0; 50 | 51 | if (i > 0) 52 | { 53 | left = nums[i] * i - prefixSum[i]; 54 | } 55 | 56 | result[i] = left + right; 57 | } 58 | 59 | return result; 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /Algorith_A_Day/Recursion/N-th_Tribonacci_Number_1137.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Algorithm_A_Day.Recursion 6 | { 7 | /// 8 | // x y z 9 | // T_3 = 0 + 1 + 1 = 2 10 | // T_4 = 1 + 1 + 2 = 4 11 | // T_5 = 1 + 2 + 4 = 7 12 | // T_6 = 2 + 4 + 7 = 13 13 | // T_7 = 4 + 7 + 13 = 24 14 | /// 15 | public class N_th_Tribonacci_Number_1137 16 | { 17 | // iteratively 18 | public static int Tribonacci(int n) 19 | { 20 | if (n == 0) return 0; 21 | if (n == 1 || n == 2) return 1; 22 | 23 | int x = 0, y = 1, z = 1; 24 | int result = 0; 25 | 26 | for (int i = 3; i <= n; i++) 27 | { 28 | result = x + y + z; 29 | x = y; 30 | y = z; 31 | z = result; 32 | } 33 | 34 | return result; 35 | } 36 | //reciursively 37 | public static int Tribonacci2(int n) 38 | { 39 | if (n == 0) return 0; 40 | else if (n == 1 || n == 2) return 1; 41 | else 42 | { 43 | return Tribonacci2(n - 1) + Tribonacci2(n - 2) + Tribonacci(n -3); 44 | 45 | } 46 | } 47 | } 48 | 49 | 50 | } 51 | -------------------------------------------------------------------------------- /Algorith_A_Day/Recursion/Reverse_String_LC_344_E.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Algorithm_A_Day.Recursion 6 | { 7 | public class Reverse_String_LC_344_E 8 | { 9 | // recursive 10 | public static void ReverseString(char[] s) 11 | { 12 | if (s == null || s.Length == 0) return; 13 | 14 | helper(s, 0, s.Length - 1); 15 | } 16 | 17 | private static void helper(char[] s, int start, int end) 18 | { 19 | if (start > end) return; 20 | var temp = s[start]; 21 | s[start] = s[end]; 22 | s[end] = temp; 23 | helper(s, start + 1, end - 1); 24 | } 25 | 26 | // same but interatively 27 | public void ReverseString2(char[] s) 28 | { 29 | var n = s.Length; 30 | var left = 0; 31 | var right = n - 1; 32 | 33 | while (left < right) 34 | { 35 | var temp = s[left]; 36 | s[left] = s[right]; 37 | s[right] = temp; 38 | left++; 39 | right--; 40 | } 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Algorith_A_Day/RecursiveToDeal/IDKrecursiveMethods.cs: -------------------------------------------------------------------------------- 1 | using Algorithm_A_Day.NodesModels; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Algorithm_A_Day.RecursiveToDeal 7 | { 8 | public class IDKrecursiveMethods 9 | { 10 | public int MinDepth(TreeNode root) 11 | { 12 | if (root == null) return 0; 13 | if (root.left == null) return 1 + MinDepth(root.right); 14 | if (root.right == null) return 1 + MinDepth(root.left); 15 | return 1 + Math.Min(MinDepth(root.left), MinDepth(root.right)); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Algorith_A_Day/RecursiveToDeal/RecursionToUnderstand.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace BST.Recursion 7 | { 8 | class RecursionToUnderstand 9 | { 10 | //We create recursion base case in helper methods(here calculate) thus create int s as argument for method 11 | //then first loop starts with index of s (from argument) and inner loop starts with the same index + 1(next one) 12 | //then we compare element from arr on index start with next one (+1) if first is smaller than next 13 | //method is called recursively 14 | 15 | public int MaxProfit(int[] prices) 16 | { 17 | return Calculate(prices, 0); 18 | } 19 | //[7,1,5,3,6,4] 7 20 | public int Calculate(int[] prices, int s) 21 | { 22 | if (s >= prices.Length) 23 | return 0; 24 | int max = 0; 25 | for (int start = s; start < prices.Length; start++) 26 | { 27 | int maxprofit = 0; 28 | for (int i = start + 1; i < prices.Length; i++) 29 | { 30 | if (prices[start] < prices[i]) 31 | { 32 | int profit = Calculate(prices, i + 1) + prices[i] - prices[start]; 33 | if (profit > maxprofit) 34 | maxprofit = profit; 35 | } 36 | } 37 | if (maxprofit > max) 38 | max = maxprofit; 39 | } 40 | return max; 41 | } 42 | //inner loop comes back with i = 4 + 1 so next one afeter calling 43 | //so profit = 3 so 3 > 0 maxprofit = 3 44 | //C(prices, 5) returns 0; 45 | //outer loop doesnt triggers with start = 6 becouse it equals to len 46 | //maxp = 0, max = 0; 47 | //C(prices, 5) i = 6 so second loop is not working here 48 | //profit = C(prices, 5) + 6 -3 49 | //3(start = 3) < 6(i = 4) 50 | //C(prices, 3) we start first loop with index 3 so with the next one after it was smaller than next XDDD 51 | //profit = C(prices, 3) + 5 -1 52 | //1(start = 1) < 5(i = 2) 53 | //all elements are smaller than 7 so now start is at index 1(value 1) 54 | //C(prices, 0)max = 0 , mp = 0; second loop is for compering all elements to first element then all to second and so on 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /Algorith_A_Day/Sorting/BubbleSort/BubbleSortPlain.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Algorithm_A_Day.Sorting.BubbleSort 6 | { 7 | /// 8 | /// Goal: sort an array. Here every el is compared with next one thus 9 | /// every position i will be compared with i+1 in every pass 10 | /// TC is O(n^2) and SC is 11 | /// 12 | class BubbleSortPlain 13 | { 14 | public static int[] BubbleSort(int[] arr) 15 | { 16 | for (int i = 0; i < arr.Length; i++) 17 | { 18 | //we dont use i value so it just says how many passes there is 19 | //it is len - 1 because otherwise it would throw an out of bounds error 20 | //for len == 8 max j is 6, cause j +1 = 7 which is in bounds 21 | //OPTIMIZATION: we substract i as well as -1 for each iteration 22 | //because every time inner loop finish the last elemtnt is at its place 23 | //so we dont need to take it under consideration : 24 | //for { 8, 9, 10, 2, 5, 6, 7 } len = 7 25 | //after 1st full iteration of this loop arr = { 8, 9, 2, 5, 6, 7, 10 } where 10 is moved to 6 index 26 | //j < 5 (7- 1-1) so the biggest j can get is 4 and j+1 = 5 where arr[4] = 6 ,arr[5] = 7 27 | //after 2nd full iteration of this loop arr = { 8, 2, 5, 6, 7, 9, 10 } where 9 is moved to 5 index 28 | //j < 4 (7- 2-1) so the biggest j can get is 3 and j+1 = 4 where arr[3] = 6, arr[4] = 7 29 | //====thus we will be getting one larger element fixed at last position===== 30 | for (int j = 0; j < arr.Length - i -1; j++) 31 | { 32 | if(arr[j] > arr[j + 1]) 33 | { 34 | int temp = arr[j]; 35 | arr[j] = arr[j + 1]; 36 | arr[j + 1] = temp; 37 | } 38 | } 39 | } 40 | return arr; 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Algorith_A_Day/Sorting/BubbleSort/SortColors.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Algorithm_A_Day.Sorting.BubbleSort 6 | { 7 | /// 8 | /// Leetcode 75. Sort Colors 9 | /// Given an array with n numbers 0, 1 or 2, 10 | /// sort them in-place so that numbers of the same value are adjacent, 11 | /// for { 2, 0, 2, 1, 1, 0 } its { 0, 0, 1, 1, 2, 2 } 12 | /// I can be solved by any sorting algo here bubble sort 13 | /// 14 | class SortColors 15 | { 16 | public static void SortColorsMethod(int[] nums) 17 | { 18 | for (int i = 0; i < nums.Length; i++) 19 | { 20 | for (int j = 0; j < nums.Length - 1 - i; j++) 21 | { 22 | if (nums[j] > nums[j + 1]) 23 | { 24 | int temp = nums[j]; 25 | nums[j] = nums[j + 1]; 26 | nums[j + 1] = temp; 27 | } 28 | } 29 | } 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Algorith_A_Day/Sorting/InsertionSort/Insertion sort.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Algorithm_A_Day.Sorting.InsertionSort 6 | { 7 | /// 8 | /// Insertion sort in simple terms compare elements. 9 | /// If element is smaller than element on the left, we swap them. 10 | /// We swap the element until element on the left is bigger. 11 | /// Worst Case Time Complexity [ Big-O ]: O(n2) 12 | /// https://www.interviewbit.com/tutorial/insertion-sort-algorithm/ 13 | /// 14 | public class Insertion_sort 15 | { 16 | public static int[] InsertionSortPlain(int[] arr) 17 | { 18 | for (int i = 1; i < arr.Length; ++i) 19 | { 20 | int key = arr[i]; 21 | int j = i - 1; 22 | 23 | // Move elements of arr[0..i-1], 24 | // that are greater than key, 25 | // to one position ahead of 26 | // their current position 27 | while (j >= 0 && arr[j] > key) 28 | { 29 | var temp = arr[j]; 30 | arr[j] = arr[j + 1]; 31 | arr[j + 1] = temp; 32 | j--; 33 | } 34 | } 35 | return arr; 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Algorith_A_Day/Sorting/MergeSort/MS with 2 arrays.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Algorithm_A_Day.Sorting.MergeSort 6 | { 7 | public class MS_with_2_arrays 8 | { 9 | public static void MergeSort2(int[] arr, int l, int r) 10 | { 11 | if (l < r) 12 | { 13 | int m = (l + r) / 2; 14 | 15 | MergeSort2(arr, l, m); 16 | MergeSort2(arr, m + 1, r); 17 | Merge(arr, l, m, r); 18 | } 19 | } 20 | 21 | private static void Merge(int[] arr, int l, int m, int r) 22 | { 23 | int i, j, k; 24 | int n1 = m - l + 1; 25 | int n2 = r - m; 26 | 27 | var L = new int[n1]; 28 | var R = new int[n2]; 29 | 30 | for (i = 0; i < n1; i++) 31 | { 32 | L[i] = arr[l + i]; 33 | } 34 | 35 | for (j = 0; j < n2; j++) 36 | { 37 | R[j] = arr[m + 1 +j]; 38 | } 39 | i = 0; 40 | j = 0; 41 | k = l; 42 | 43 | while(i < n1 && j < n2) 44 | { 45 | if(L[i] <= R[j]) 46 | { 47 | arr[k] = L[i]; 48 | i++; 49 | } 50 | else 51 | { 52 | arr[k] = R[j]; 53 | j++; 54 | } 55 | k++; 56 | } 57 | while (i < n1) 58 | { 59 | arr[k] = L[i]; 60 | i++; 61 | k++; 62 | } 63 | while (j < n2) 64 | { 65 | arr[k] = R[j]; 66 | j++; 67 | k++; 68 | } 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /Algorith_A_Day/Sorting/SelectionSort/SelectionSort.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Algorithm_A_Day.Sorting.SelectionSort 6 | { 7 | /// 8 | /// Selection sort is IN-PLACE sort. 9 | /// It is build from left to right. 10 | /// Genral rules: 1.Compare first el to the rest and swap it with the smallest, 11 | /// 1.5 in other words from the rest indexes compare the one vales chose one and swap it with choses first element 12 | /// 2. Change the first el to the next 13 | /// 3. step 1 and 2 again utnil the el at arr.len -2 as last el is sorted automatically 14 | /// 4. outer loop is for setting the current elemnt to compare and innner is for comparing 15 | /// TC - O(n^2) so inefficient on large lists 16 | /// 17 | public class SelectionSort 18 | { 19 | public static int[] SelectionSortPlain(int[] arr) 20 | { 21 | // it is arr.Length -1 because the last el left is on its place 22 | // and we comper next el 23 | for (int i = 0; i < arr.Length -1; i++) 24 | { 25 | var min = i; 26 | for (int j = i + 1; j < arr.Length; j++) 27 | { 28 | if (arr[j] < arr[min]) 29 | { 30 | min = j; 31 | } 32 | } 33 | 34 | //if min == i that means we dont have swap because no chang was made 35 | // min != i that means there is an smaller el than current one and a swap is needed 36 | if (min != i) 37 | { 38 | var temp = arr[min]; 39 | arr[min] = arr[i]; 40 | arr[i] = temp; 41 | } 42 | } 43 | return arr; 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Algorith_A_Day/String operations/Longest Sub-String.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Algorithm_A_Day.String_operations 6 | { 7 | //TODO: compare to example in Algo file 8 | public class Longest_Sub_String 9 | { 10 | public static string GetLongestSubString(string input) 11 | { 12 | int maxLen = 0; 13 | int currentLen = 1; 14 | string result = input[0].ToString(); 15 | char currentChar = input[0]; 16 | 17 | for (int i = 1; i < input.Length; i++) 18 | { 19 | if(input[i] == currentChar) 20 | { 21 | currentLen++; 22 | if(maxLen < currentLen) 23 | { 24 | maxLen = currentLen; 25 | result = new string(currentChar, maxLen); 26 | continue; 27 | } 28 | if(result[0] == input[i]) 29 | { 30 | result += input[i]; 31 | } 32 | } 33 | else 34 | { 35 | currentLen = 1; 36 | currentChar = input[i]; 37 | } 38 | } 39 | if (result == null) return input[0].ToString(); 40 | 41 | return result; 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Algorith_A_Day/String operations/Pramp/Smallest_Substring_Of_All_Chars.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Algorithm_A_Day.String_operations.Pramp 6 | { 7 | //todo: to do XD 8 | public class Smallest_Substring_Of_All_Chars 9 | { 10 | //public static GetShortestUniqueSubstring(char[] arr, string str) 11 | //{ 12 | 13 | //} 14 | 15 | // arr.len = 3, 0-2 if constains all 1 -3 2-4 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Algorith_A_Day/String operations/RevertAString.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace Algorithm_A_Day.String_operations 7 | { 8 | class RevertAString 9 | { 10 | public static string RevertString(string input) 11 | { 12 | string result = String.Empty; 13 | for (int i = input.Length - 1; i >= 0; i--) 14 | { 15 | result += input[i]; 16 | } 17 | string reverseValue = new string(input.Reverse().ToArray()); 18 | var result2 = input.Aggregate("", (acc, c) => c + acc); 19 | //"",("",d) => d+"" 20 | // (d,u) => u + d 21 | // (ud,p) => p + ud 22 | // (pud,a) => a + pud = apud XDDD 23 | var result3 = input.Aggregate(new StringBuilder(), (x, y) => x.Insert(0, y)).ToString(); 24 | //public string Insert(int startIndex, string value); 25 | //"",("",d) => sb.Insert(0,d) 26 | // (d,u) => d.Insert(0,u) = ud(inserting u at index 0 + the rest ("d") 27 | // (ud, p) => ud.Insert(0,p) = pud(inserting p at index 0 + the rest ("ud")) 28 | // (pud,a) => pud.Insert(0,a) = apud(inserting a at index 0 + the rest ("pud") 29 | 30 | var result4 = input.ToCharArray()//it is not necessary here 31 | .Select(ch => ch.ToString()) 32 | .Aggregate((xs, x) => x + xs); 33 | Func f = null; f = s => s.Length == 1 ? s : f(s.Substring(1)) + s[0]; 34 | //f(dupa) = f(upa) + d 35 | //f(upa) = f(pa) + u 36 | //f(pa) = f(a) + p 37 | //f(a) = a, here "s.Length == 1 ? s" is a BASE CASE 38 | var result5 = f(input); 39 | 40 | //todo 41 | var result6 = new string(Enumerable.Range(1, input.Length).Select(i => input[input.Length - i]).ToArray()); 42 | 43 | var result7 = new string(input.Select((c, index) => new { c, index }) 44 | .OrderByDescending(x => x.index) 45 | .Select(x => x.c) 46 | .ToArray()); 47 | return result3; 48 | } 49 | } 50 | } 51 | --------------------------------------------------------------------------------