public void ExecuteTest() { var strs = new[] { "flower", "flow", "flight" }; var expected = "fl"; LongestCommonPrefix.Execute(strs).Should().Be(expected); }
public void StringsCanShareCommonPrefix() { var input = new[] { "aab", "aabcd" }; var lcp = new LongestCommonPrefix(); Assert.Equal("aab", lcp.longestCommonPrefix(input)); }
public void NoCommonPrefixReturnsEmptyString() { var input = new[] { "cat", "bat", "hat" }; var lcp = new LongestCommonPrefix(); Assert.Equal("", lcp.longestCommonPrefix(input)); }
public void ExecuteTest2() { var strs = new[] { "dog", "racecar", "car" }; var expected = ""; LongestCommonPrefix.Execute(strs).Should().Be(expected); }
public void GetLongestCommonPrefix_flower_flow_flight() { var srv = new LongestCommonPrefix(); string s = srv.GetLongestCommonPrefix(new string[] { "flower", "flow", "flight" }); Assert.AreEqual("fl", s); }
public void GetLongestCommonPrefix_dog_racecar_car() { var srv = new LongestCommonPrefix(); string s = srv.GetLongestCommonPrefix(new string[] { "dog", "racecar", "car" }); Assert.AreEqual("", s); }
public void TestEmptyPrefix() { LongestCommonPrefix longestCommonPrefix = new LongestCommonPrefix(); string[] stringArray = new string[] { "abc", "efg" }; string prefix = longestCommonPrefix.GetLongestCommonPrefix(stringArray); Assert.AreEqual("", prefix); }
public static void Main(string[] args) { //var result = ReverseInteger.Reverse(123); //var result = Palindrome.IsPalindrome(123); var result = LongestCommonPrefix.FindLongestCommonPrefix(new string[] { "dog", "racecar", "car" }); Console.WriteLine(result); Console.ReadLine(); }
public void Excution1Test() { var fun = new LongestCommonPrefix(); Assert.AreEqual("fl", fun.Excution1(new string[] { "flower", "flow", "flight" })); Assert.AreEqual(string.Empty, fun.Excution1(new string[] { "dog", "racecar", "car" })); Assert.AreEqual(string.Empty, fun.Excution1(new string[] { })); }
public void TestLongestCommonPrefix() { var r = LongestCommonPrefix.S1(new [] { "abcefg", "abcd", "ab" }); Assert.AreEqual(r, "ab"); r = LongestCommonPrefix.S2Binary(new[] { "abckkkkefg", "abckk", "abckkkdddd" }); Assert.AreEqual(r, "abckk"); r = LongestCommonPrefix.S2Binary(new[] { "", "abckk", "abckkkdddd" }); Assert.AreEqual(r, ""); }
private static void LongestCommonPrefixTest() { Console.WriteLine("\nLongest Common Prefix question:"); LongestCommonPrefix longestCommonPrefix = new LongestCommonPrefix(); IList <string[]> testStringArrays = new List <string[]> { new string[] { "flower", "flow", "flight" }, new string[] { "dog", "racecar", "car" }, new string[] { } }; foreach (string[] stringArray in testStringArrays) { Console.WriteLine("[{0}] -> {1}", string.Join(", ", stringArray), longestCommonPrefix.LongestCommonPrefixOne(stringArray)); } }
public void BeforeEach() { LongestCommonPrefix = new LongestCommonPrefix(); }
public LongestCommonPrefixTests() { _testsVerifier = new TestsVerifier(); _objUnderTest = new LongestCommonPrefix(); }
void InternalTest(string[] strs, string expected) { string actual = LongestCommonPrefix.Solve(strs); Assert.Equal(expected, actual); }
public void FindPrefix_PassedFStringArray_Returnsf() { string[] input = new string[] { "flower", "flow", "fello", "fleet" }; Assert.AreEqual("f", LongestCommonPrefix.FindPrefix(input)); }
public void When_single_Then_whole_word() { Assert.AreEqual("abcgd", LongestCommonPrefix.LongestCommonPrefixFunc(new[] { "abcgd" })); }
public void Find(string[] array, string expectedProfix) { var result = new LongestCommonPrefix().Find(array); result.Should().Be(expectedProfix); }
static void Main(string[] args) { SortedMatrixSearch.Run(); SparseSearch.Run(); SearchInRotatedArray.Run(); GroupAnagrams.Run(); CombinationsOfNPairsParentheses.Run(); PermutationWithDuplicates.Run(); PermutationNoDuplicates.Run(); var subsetList = new List <List <int> >(); subsetList = SubsetInSet.FindAllSubsetInSet(new List <int> { 1, 2, 3 }); ReverseLinkedList.Run(); IsUniqueString.Run(); StoneDivisionProblem.Run(); Kangaroo.Run(); AppleAndOrange.Run(); AbbreviationProblem.Run(); FibonacciModifiedProblem.Run(); RecursiveDigitSum.Run(); RangeSumOfBST.Run(); GradingStudentsProblem.Run(); // XorSequenceProblem.Run(); CounterGameProblem.Run(); MaximizingXORProblem.Run(); LonelyIntegerProblem.Run(); FlippingBitsProblem.Run(); QueueUsingTwoStacksProblem.Run(); GetNodeValue.Run(); MergeTwoSortedLinkedLists.Run(); Compare_Two_linked_lists.Run(); DeleteNodeProblem.Run(); ArrayManipulationProblem.Run(); LeftRotationProblem.Run(); HourGlass2D.Run(); SimpleTextEditorProblem.Run(); EqualStacksProblem.Run(); MaximumElementProblem.Run(); BinarySearchTreeInsertion.Run(); TopViewProblem.Run(); TimeConvertsionProblem.Run(); BinaryTreePathsProblem.Run(); IncreasingOrderSearchTree.Run(); RemoveAllAdjacentDuplicatesInStringWithKLength.Run(); RemoveAllAdjacentDuplicatesInString.Run(); CheckStraightLineProblem.Run(); HouseRobber.Run(); UniquePathsProblem.Run(); FirstUniqueCharacterInString.Run(); BinaryTreeInorderTraversal.Run(); DailyTemperaturesProblem.Run(); CountingBitsproblem.Run(); SortIntegersByTheNumberOf1BitsProblem.Run(); HammingDistanceProblem.Run(); RansomNoteProblem.Run(); ConvertBinaryNumberInLinkedListToIntegerProblem.Run(); NumberOfStepsToReduceNumberToZeroProblem.Run(); JewelsAndStones.Run(); ClimbingStairsProblem.Run(); BestTimeToBuyAndSellStock.Run(); MajorityElementProblem.Run(); MoveZeroesProblem.Run(); InvertBinaryTree.Run(); SingleNumberProblem.Run(); MaximumDepthInTrree.Run(); MergeTwoBinaryTrees.Run(); AddBinaryProblem.Run(); PlusOneProblem.Run(); LengthOfLastWordProblem.Run(); KadaneAlgorithmForMaxSubArray.Run(); KMPAlgorithm.Run(); CountAndSayProblem.Run(); SearchInsertPosition.Run(); ImplementIndexOfString.Run(); RemoveElement.Run(); RemoveDuplicatesFromSortedArray.Run(); MergeTwoSortedLists.Run(); ValidParentheses.Run(); LongestCommonPrefix.Run(); RomanToInteger.Run(); PalindromeNumber.Run(); ReverseInteger.Run(); TwoSumProblem.Run(); AddOneToNumber.Run(); MostAmountOfChange.Run(); #region BinaryTree LeastCommonAncestor.Run(); PrintAllPaths.Run(); HasPathSum.Run(); CheckIfBinaryTreeIsBinarySearchTree.Run(); PrintAllNodesWithRangeInBinarySearchTree.Run(); UniqueTreeStructureNumber.Run(); MirrorTree.Run(); #region BitManuiplation_GetNthNumber NumberOfStepsToReduceNumberToZeroProblem.Run(); CountNumbersOf1InBit.Run(); ReverseThebitsInInteger.Run(); PrintBitsInInteger.Run(); GetNthBit.Run(); setNthBitTo1.Run(); SetNthBitTo0.Run(); #endregion MinimumtValueInTrree minValueInTree = new MinimumtValueInTrree(); minValueInTree.Run(); #endregion #region Recursion Chessboard chessboard = new Chessboard(); chessboard.Run(); RatPathToMaze ratPathToMaze = new RatPathToMaze(); ratPathToMaze.Run(); List <string> anagramList = new List <string>(); anagramList = WordAnagram.GenerateWordAnagram("abc"); Pixel[,] pixelList = new Pixel[3, 3] { { new Pixel(0, 0, "red"), new Pixel(0, 1, "green"), new Pixel(0, 2, "green") }, { new Pixel(1, 0, "red"), new Pixel(1, 1, "green"), new Pixel(1, 2, "green") }, { new Pixel(2, 0, "red"), new Pixel(2, 1, "green"), new Pixel(2, 2, "green") } }; FillPaint.PaintFill(pixelList, 1, 2, "green", "black"); BinaryTreesAreTheSame.Run(); #endregion #region General problems RotateArrayByKSpaces.Run(); #region AddtwoNumbersReferencedByTheirDigits var addRes = AddtwoNumbersReferencedByTheirDigits.AddNumbers(new int[] { 1, 2, 7 }, new int[] { 9, 4 }); #endregion #region RunLengthEncoding var encodedStr = RunLengthEncoding.Encode("aabbbbc"); var decodedStr = RunLengthEncoding.Decode(encodedStr); #endregion #region BreakDocumentIntoChunk var chunkRes = BreakDocumentIntoChunk.Chunkify("ab:dd:ddfcct:aab:cccc", ':', 5); #endregion #region GameOfLife var gameRes = GameOfLife.GetNextInteration(new int[3, 3] { { 1, 0, 0 }, { 0, 1, 1 }, { 1, 0, 0 } }); #endregion . #endregion #region InsertionSort InsertionSort.insertionSort(listToSort); #endregion #region BinarySearch Console.WriteLine(String.Format("%s is present at index: %s", 30, BinarySearch.binarySearch(sortedArray, 30, 0, sortedArray.Length - 1))); Console.WriteLine(String.Format("%s is present at index: %s", 4, BinarySearch.binarySearch(sortedArray, 4, 0, sortedArray.Length - 1))); Console.WriteLine(String.Format("%s is present at index: %s", 15, BinarySearch.binarySearch(sortedArray, 15, 0, sortedArray.Length - 1))); #endregion #region MergeSort MergeSort.print(listToSort); MergeSort.mergeSort(listToSort); #endregion #region QuickSort QuickSort.print(listToSort); QuickSort.quickSort(listToSort, 0, listToSort.Length - 1); QuickSort.print(listToSort); #endregion }
public void When_tow_Then_same_prefix() { Assert.AreEqual("ab", LongestCommonPrefix.LongestCommonPrefixFunc(new[] { "abcgd", "absadfsdaf" })); }
public void ReturnsEmptyStringForNoInput() { var lcp = new LongestCommonPrefix(); Assert.Equal("", lcp.longestCommonPrefix(null)); }
public void When_empty_Then_whole_word() { Assert.AreEqual(string.Empty, LongestCommonPrefix.LongestCommonPrefixFunc(new string[] { })); }
public void Setup() { _kata = new LongestCommonPrefix(); }
private void oldProblems() { LongestCommonPrefix.Run(); ConvertToBase.Run(); PalindromeString.Run(); }
public void FindPrefix1_PassedNoCommonPrefixStringArray_ReturnsEmptyString() { string[] input = new string[] { "abc", "def", "ghi" }; Assert.AreEqual("", LongestCommonPrefix.FindPrefix1(input)); }
public void Case1() { var r = new LongestCommonPrefix().Go(new string[] { "flower", "flow", "flight" }); Assert.AreEqual("fl", r); }
public void Case2() { var r = new LongestCommonPrefix().Go(new string[] { "dog", "racecar", "car" }); Assert.AreEqual("", r); }