Пример #1
0
        private void RunTwo(MaxXorUseTrie maxXor)
        {
            Console.WriteLine("Elements of Two =====================");
            int[] values;
            int   max;

            values = new int[] { 3, 10, 5, 25, 2, 8 };
            max    = maxXor.FindTwo(values);
            Console.WriteLine($"The max xor of {string.Join(",", values)} is {max}");

            values = new int[] { 3, 10, 5, 25 };
            max    = maxXor.FindTwo(values);
            Console.WriteLine($"The max xor of {string.Join(",", values)} is {max}");

            values = new int[] { 3, 10, 5 + 16, 25 };
            max    = maxXor.FindTwo(values);
            Console.WriteLine($"The max xor of {string.Join(",", values)} is {max}");

            values = new int[] { 16 + 3, 16 + 10, 16 + 5, 25 };
            max    = maxXor.FindTwo(values);
            Console.WriteLine($"The max xor of {string.Join(",", values)} is {max}");

            values = new int[] { 10, 2, 8 };
            max    = maxXor.FindTwo(values);
            Console.WriteLine($"The max xor of {string.Join(",", values)} is {max}");
        }
Пример #2
0
        public void Run()
        {
            Console.WriteLine("Trie =====================");
            MaxXorUseTrie maxXor = new MaxXorUseTrie();

            // RunTwo(maxXor);
            // RunAnyOfArray(maxXor);
            RunLessThanCountOfArray(maxXor);
        }
Пример #3
0
        private void RunLessThanCountOfArray(MaxXorUseTrie maxXor)
        {
            Console.WriteLine("LessThanCount Elements of Array =====================");
            int[] values;
            int   count, k;

            values = new int[] { 1, 2, 3, 4 };
            k      = 7;
            count  = maxXor.FindLessThanCountOfArray(values, k);
            Console.WriteLine($"The xor's count less than {k} of {string.Join(",", values)} is {count}");

            values = new int[] { 8, 1, 2, 12, 7, 6 };
            k      = 10;
            count  = maxXor.FindLessThanCountOfArray(values, k);
            Console.WriteLine($"The xor's count less than {k} of {string.Join(",", values)} is {count}");

            values = new int[] { 9, 7, 4, 3 };
            k      = 6;
            count  = maxXor.FindLessThanCountOfArray(values, k);
            Console.WriteLine($"The xor's count less than {k} of {string.Join(",", values)} is {count}");
        }
Пример #4
0
        private void RunAnyOfArray(MaxXorUseTrie maxXor)
        {
            Console.WriteLine("Elements of Array =====================");
            int[] values;
            int   maxWithTrie;

            values      = new int[] { 1, 2, 3, 4 };
            maxWithTrie = maxXor.FindAnyOfArray(values);
            Console.WriteLine($"The max xor of {string.Join(",", values)} is {maxWithTrie}");

            values      = new int[] { 8, 1, 2, 12, 7, 6 };
            maxWithTrie = maxXor.FindAnyOfArray(values);
            Console.WriteLine($"The max xor of {string.Join(",", values)} is {maxWithTrie}");

            values      = new int[] { 4, 6 };
            maxWithTrie = maxXor.FindAnyOfArray(values);
            Console.WriteLine($"The max xor of {string.Join(",", values)} is {maxWithTrie}");

            values      = new int[] { 9, 7, 4, 3 };
            maxWithTrie = maxXor.FindAnyOfArray(values);
            Console.WriteLine($"The max xor of {string.Join(",", values)} is {maxWithTrie}");
        }