Example #1
0
        private static void FirstBadVersion()
        {
            int         n           = 4;
            SortNSearch sortNSearch = new SortNSearch();

            sortNSearch.FirstBadVersion(n);
        }
Example #2
0
        private static void MergeSortedArrays()
        {
            int[]       nums1       = new int[] { 1, 2, 3, 0, 0, 0 };
            int[]       nums2       = new int[] { 2, 5, 6 };
            SortNSearch sortNSearch = new SortNSearch();

            sortNSearch.MergeSortedArrays(nums1, 3, nums2, 3);
        }
Example #3
0
        private static void SearchRotated()
        {
            int[]       arr         = { 4, 5, 6, 7, 8, 9, 1, 2, 3 };
            int         target      = 6;
            SortNSearch sortNSearch = new SortNSearch();

            sortNSearch.SearchRotated(arr, target);
        }
Example #4
0
        private static void SearchRoatedDuplicate()
        {
            int[]       arr         = { 1, 3, 1, 1, 1 };
            int         target      = 3;
            SortNSearch sortNSearch = new SortNSearch();

            Console.WriteLine(sortNSearch.SearchRoatedDuplicate(arr, target));
        }
Example #5
0
        private static void MergeIntervals()
        {
            var intervals = new List <Interval>()
            {
                new Interval(1, 4), new Interval(0, 4)
            };
            SortNSearch sortNSearch = new SortNSearch();

            sortNSearch.MergeIntervals(intervals);
        }
Example #6
0
        private static void CanAttendMeetings()
        {
            var intervals = new List <Interval>()
            {
                new Interval(5, 10), new Interval(0, 30), new Interval(15, 20)
            };
            SortNSearch sortNSearch = new SortNSearch();

            sortNSearch.CanAttendMeetings(intervals.ToArray());
        }
Example #7
0
        private static void MergeTwoLists()
        {
            ListNode l1 = new ListNode(1);

            l1.next      = new ListNode(2);
            l1.next.next = new ListNode(4);
            ListNode l2 = new ListNode(1);

            l2.next      = new ListNode(3);
            l2.next.next = new ListNode(4);
            SortNSearch sortNSearch = new SortNSearch();

            sortNSearch.MergeTwoLists(l1, l2);
        }