Exemplo n.º 1
0
        public void LongestCommonStringTest()
        {
            string a = "zxabcdezy", b = "yzabcdezx";

            Batch4 b4  = new Batch4();
            int    len = b4.LongestCommonString(a, b);
        }
Exemplo n.º 2
0
 public void MinSwapTest()
 {
     int[]  A   = { 1, 3, 5, 4 };
     int[]  B   = { 1, 2, 3, 7 };
     Batch4 b4  = new Batch4();
     int    num = b4.MinSwap(A, B);
 }
Exemplo n.º 3
0
        public void FindMin2Test()
        {
            Batch4 b4 = new Batch4();

            int[] nums = { 2, 0, 1, 1, 1 };
            int   min  = b4.FindMin2(nums);
        }
Exemplo n.º 4
0
        public void FindItineraryTest()
        {
            Batch4 b4 = new Batch4();

            //[["MUC","LHR"],["JFK","MUC"],["SFO","SJC"],["LHR","SFO"]]
            IList <IList <string> > tickets = new List <IList <string> >();
            List <string>           tempList;

            tempList = new List <string>();
            tempList.Add("MUC");
            tempList.Add("LHR");
            tickets.Add(tempList);

            tempList = new List <string>();
            tempList.Add("JFK");
            tempList.Add("MUC");
            tickets.Add(tempList);

            tempList = new List <string>();
            tempList.Add("SFO");
            tempList.Add("SJC");
            tickets.Add(tempList);

            tempList = new List <string>();
            tempList.Add("LHR");
            tempList.Add("SFO");
            tickets.Add(tempList);

            IList <string> routes = b4.FindItinerary(tickets);
        }
Exemplo n.º 5
0
        public void KnapsackTest()
        {
            int[] weight = { 5, 4, 6, 7 };
            int[] value  = { 10, 40, 30, 70 };

            Batch4 b4  = new Batch4();
            int    max = b4.Knapsack(weight.Length, 9, weight, value);
        }
Exemplo n.º 6
0
        public void UniquePathsWithObstaclesTest()
        {
            //[[0,0,0],[0,1,0],[0,0,0]]

            int[][] arr = new int[][] { new int[] { 0, 0, 0 }, new int[] { 0, 1, 0 }, new int[] { 0, 0, 0 } };

            Batch4 b4     = new Batch4();
            int    nPaths = b4.UniquePathsWithObstacles(arr);
        }
Exemplo n.º 7
0
        public void FindLongestChainTest()
        {
            //[[-6,9],[1,6],[8,10],[-1,4],[-6,-2],[-9,8],[-5,3],[0,3]]
            Batch4 b4 = new Batch4();

            int[][] pairs = new int[][]
            {
                new int[] { -6, 9 },
                new int[] { 1, 6 },
                new int[] { 8, 10 },
                new int[] { -1, 4 },
                new int [] { -6, -2 },
                new int [] { -9, 8 },
                new int [] { -5, 3 },
                new int [] { 0, 3 }
            };
            b4.FindLongestChain(pairs);
        }
Exemplo n.º 8
0
 public void LongestValidParenthesesTest()
 {
     Batch4 b4 = new Batch4();
     int    l  = b4.LongestValidParentheses("()(())");
 }
Exemplo n.º 9
0
 public void SolveNQueensTest()
 {
     Batch4 b4 = new Batch4();
     IList <IList <string> > result = b4.SolveNQueens(4);
 }
Exemplo n.º 10
0
 public void FindNumberOfLISTest()
 {
     int[]  a      = { 1, 2, 4, 3, 5, 4, 7, 2 };
     Batch4 b4     = new Batch4();
     int    result = b4.FindNumberOfLIS(a);
 }
Exemplo n.º 11
0
 public void NumTilingsTest()
 {
     int    n  = 30;
     Batch4 b4 = new Batch4();
     int    v  = b4.NumTilings(30);
 }
Exemplo n.º 12
0
        public void FrequencySortTest()
        {
            Batch4 b4 = new Batch4();

            string result = b4.FrequencySort("aDDbbbcAc");
        }