示例#1
0
        static void TwoSum()
        {
            int[] nums = new int[4] {
                2, 7, 11, 15
            };

            var leetroot = new LeetCode();

            //var retVal = leetroot.TwoSumByHash(nums, 22);
            var retval = leetroot.TwoSumByDictionary(nums, 22);
        }
示例#2
0
        //static void AddTwoLinkedListed()
        //{
        //    var l1 = new LinkedListNode<int>(1);
        //    l1.Next =l1;
        //    l1.Next.Next.Value = 3;

        //    var l2 = new LinkedListNode<int>(3);
        //    l2.Next.Value = 7;
        //    l2.Next.Next.Value = 4;

        //    var leetroot = new LeetCode();

        //    var result = leetroot.AddTwoNumbers(l1, l2);

        //}
        #endregion

        #region string
        static void CheckPrString()
        {
            var stringList = new List <string>()
            {
                "abcde", "e", "001qw3", "abcdedcba", "abcddcba"
            };
            var leetcode = new LeetCode();

            foreach (var str in stringList)
            {
                Console.WriteLine("Loop method: " + leetcode.IsPrStrByLooping(str));
                Console.WriteLine("Receisive method: " + leetcode.IsPrByRecr(str));
            }
        }
示例#3
0
        static bool CheckAnagram(string s1, string s2)
        {
            var leetCode = new LeetCode();

            return(leetCode.IsAnagram(s1, s2));
        }