Пример #1
0
        public static void RemoveDuplicatesinLinkedList()
        {
            var number1 = new myLinkedList <int>
            {
                data = 2,
                Next = new myLinkedList <int>
                {
                    data = 5,
                    Next = new myLinkedList <int>
                    {
                        data = 6,
                        Next = new myLinkedList <int>
                        {
                            data = 5,
                            Next = new myLinkedList <int>
                            {
                                data = 9,
                                Next = new myLinkedList <int>
                                {
                                    data = 1
                                }
                            }
                        }
                    }
                }
            };

            var obj = new CareerCupQnA();

            obj.RemoveDuplicatesInLinkedList(number1);
        }
Пример #2
0
        private static void SwapPairsInLinkedList()
        {
            var linkedList = new myLinkedList <int>();
            var number1    = new myLinkedList <int>
            {
                data = 1,
                Next = new myLinkedList <int>
                {
                    data = 2,
                    Next = new myLinkedList <int>
                    {
                        data = 3,
                        Next = new myLinkedList <int>
                        {
                            data = 4,
                            Next = new myLinkedList <int>
                            {
                                data = 5
                            }
                        }
                    }
                }
            };

            var number2 = new myLinkedList <int>
            {
                data = 1,
            };

            var output = new CareerCupQnA().SwapPairs(number2);
        }
Пример #3
0
        public static void isPalindrome()
        {
            var number1 = new myLinkedList <int>
            {
                data = 1,
                Next = new myLinkedList <int>
                {
                    data = 2,
                    Next = new myLinkedList <int>
                    {
                        data = 3,
                        Next = new myLinkedList <int>
                        {
                            data = 2,
                            Next = new myLinkedList <int>
                            {
                                data = 1,
                            }
                        }
                    }
                }
            };
            var obj = new CareerCupQnA();

            Console.WriteLine(
                obj.CheckPalindromeInLinkedList(number1, new Dictionary <int, int>(), 0, 5));
        }
Пример #4
0
        public static void FindTheSubsetOfSum()
        {
            var obj = new CareerCupQnA();
            var res = obj.FindTheSubsetOfSum(new List <int> {
                1, 2, 3, 4, 5
            }, 7);

            foreach (var e in res)
            {
                Console.WriteLine(e);
            }
            Console.WriteLine("**************************");
            res = obj.FindTheSubsetOfSum(new List <int> {
                1, 2, 3, 4, 5, 6, 7, 9
            }, 8);

            foreach (var e in res)
            {
                Console.WriteLine(e);
            }
            Console.WriteLine("**************************");
            res = obj.FindTheSubsetOfSum(new List <int> {
                1, 11, 22, 33, 44, 55, 66, 77, 88, 99
            }, 100);

            foreach (var e in res)
            {
                Console.WriteLine(e);
            }
        }
Пример #5
0
        static void SumPath()
        {
            var obj   = new CareerCupQnA();
            var treeO = new TreesNGraph();

            obj.SumPath(treeO.PopulateBinarySTree(), 28);
        }
Пример #6
0
        public static void MultiplyLinkedLists()
        {
            var obj = new CareerCupQnA();

            var number1 = new myLinkedList <int>
            {
                data = 2,
                Next = new myLinkedList <int>
                {
                    data = 5,
                    Next = new myLinkedList <int>
                    {
                        data = 6
                    }
                }
            };

            var number2 = new myLinkedList <int>
            {
                data = 1,
                Next = new myLinkedList <int>
                {
                    data = 3
                }
            };

            obj.Multiply2LinkedList(number1, number2);
        }
Пример #7
0
        static void PowerOfSum()
        {
            var obj = new CareerCupQnA();
            var n   = 81;
            var p   = 2;

            obj.PowerOfSum((int)Math.Pow(n, 1.0 / p), p, 0, n);
            Console.WriteLine("-----------------------------------------------------------------------");
            n = 100;
            p = 3;

            //obj.PowerOfSum((int)Math.Pow(n, 1.0 / p), p, 0, n);
            //Console.WriteLine("-----------------------------------------------------------------------");

            //n = 1000;
            // p = 2;

            //obj.PowerOfSum((int)Math.Pow(n, 1.0 / p), p, 0, n);
            //Console.WriteLine("-----------------------------------------------------------------------");

            //n = 1000;
            //p = 5;

            //obj.PowerOfSum((int)Math.Pow(n, 1.0 / p), p, 0, n);
            //Console.WriteLine("-----------------------------------------------------------------------");
        }
Пример #8
0
        public static void StudyRecursive()
        {
            var obj = new CareerCupQnA();
            var v   = 10;

            obj.StudyRecursive(v);
            Console.WriteLine("Answer :" + v);
        }
Пример #9
0
        public static void FindItsParent()
        {
            var obj  = new CareerCupQnA();
            var obj1 = new TreesNGraph();


            obj.FindItsParent(obj1.PopulateBinaryTree(), 5, 0);
        }
Пример #10
0
        static void NonAdjacentSum()
        {
            var obj = new CareerCupQnA();

            Console.WriteLine(obj.NonAdjacentSum(new List <int> {
                3, 2, 5, 10, 7
            }));
        }
Пример #11
0
        static void FormatArray()
        {
            var obj = new CareerCupQnA();

            obj.FormatArray(new List <int> {
                1, 1, 2, 2, 2, 3, 4, 4, 4, 4, 5
            }, 1);
        }
Пример #12
0
        public static void MaxTimeOfTask()
        {
            var obj = new CareerCupQnA();

            obj.MaxTimeOfTask(new List <int> {
                5, 1, 3, 2, 5
            }, 0);
        }
Пример #13
0
        //        Ex : [-20, -5, -2, -9] :> -2(-2)
        //Ex : [20, -19, 6, 9, 4] :-> 20(20)
        //Ex : [20, -19, 6, 9, 4] -> 18 (10, -3, 4, -2, -1, 10)
        static void LargestSumOfContiguousArray()
        {
            var obj = new CareerCupQnA();

            obj.LargestSumOfContiguousArray(new int[] { -20, -5, -2, -9 });
            obj.LargestSumOfContiguousArray(new int[] { 20, -19, 6, 9, 4 });
            obj.LargestSumOfContiguousArray(new int[] { 10, -3, 4, -2, -1, 10 });
        }
Пример #14
0
        static void getMaxLen()
        {
            var obj = new CareerCupQnA();

            var res = obj.getMaxLen(new int[] { 0, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1 }, 4);

            Console.WriteLine(res);
        }
Пример #15
0
        static void CheckBST()
        {
            var obj        = new CareerCupQnA();
            var obj1       = new TreesNGraph();
            var binaryTree = obj1.PopulateBinarySTree();

            Console.WriteLine("InOrder Starts");
            Console.WriteLine(obj.CheckBST(binaryTree));
        }
Пример #16
0
        public static void MatrixTraversal()
        {
            var obj = new CareerCupQnA();

            int[,] array2D = new int[, ] {
                { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 }
            };
            obj.traversalOfMatrix(array2D, 2, 2);
        }
Пример #17
0
        static void findtheClosestManager()
        {
            var obj  = new CareerCupQnA();
            var obj1 = new TreesNGraph();
            var tree = obj1.PopulateBinaryTree();

            obj.ClosestManager(tree, 5, 10);
            Console.WriteLine("=============> {0} ", obj.GetClosestCommonManagers());
        }
Пример #18
0
        //static void KAMI()
        //{
        //    var obj = new CareerCupQnA();

        //    int[,] array2D = new int[,] { { 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1},
        //                                  { 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1},
        //                                  { 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1},
        //                                  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1},
        //                                  { 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1},
        //                                  { 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1},
        //                               };
        //    obj.KAMI(array2D, array2D.GetUpperBound(0), array2D.GetUpperBound(1));
        //}


        static void Permutation()
        {
            var obj = new CareerCupQnA();

            obj.Permutation(new List <int> {
                3, 39, 34, 5, 9
            }, 0, 4);

            Console.WriteLine("Maximum number is {0}", obj.Max);
        }
Пример #19
0
        static void RemoveDuplicatesInStringRecursion()
        {
            var s = "aaabbbbccccddef";

            var obj = new CareerCupQnA();

            var res = obj.RemoveDuplicatesInStringRecursion(s, 0);

            Console.WriteLine(res);
        }
Пример #20
0
        static void MetaString()
        {
            var obj = new CareerCupQnA();

            Console.WriteLine(obj.IsMetaString("converse".ToArray(), "conserve".ToArray()));
            Console.WriteLine(obj.IsMetaString("converse".ToArray(), "conserse".ToArray()));
            Console.WriteLine(obj.IsMetaString("converse".ToArray(), "converse".ToArray()));
            Console.WriteLine(obj.IsMetaString("converse".ToArray(), "conseeee".ToArray()));
            Console.WriteLine(obj.IsMetaString("manoj".ToArray(), "conseeee".ToArray()));
            Console.WriteLine(obj.IsMetaString("manoj".ToArray(), "monaj".ToArray()));
        }
Пример #21
0
        public static void FindingTheMinNumberByPattern()
        {
            var obj = new CareerCupQnA();

            obj.FindtheMinNumber("D");
            obj.FindtheMinNumber("I");
            obj.FindtheMinNumber("DD");
            obj.FindtheMinNumber("II");
            obj.FindtheMinNumber("DIDI");
            obj.FindtheMinNumber("IIDDD");
            obj.FindtheMinNumber("DDIDDIID");
        }
Пример #22
0
        static void ShuffleArray()
        {
            var obj = new CareerCupQnA();
            var res = obj.ShuffleArray(new List <int> {
                3, 2, 1, 4, 4, 1, 5
            }, new List <int> {
                2, 1, 6, 3, 2, 3, 5
            });

            foreach (var c in res)
            {
                Console.WriteLine(c);
            }
        }
Пример #23
0
        static void MergeSortedArray()
        {
            var number1 = new myLinkedList <int>
            {
                data = 2,
                Next = new myLinkedList <int>
                {
                    data = 5,
                    Next = new myLinkedList <int>
                    {
                        data = 6
                    }
                }
            };

            var number2 = new myLinkedList <int>
            {
                data = 1,
                Next = new myLinkedList <int>
                {
                    data = 3,
                    Next = new myLinkedList <int>
                    {
                        data = 99,
                        Next = new myLinkedList <int>
                        {
                            data = 100,
                            Next = new myLinkedList <int>
                            {
                                data = 1009,
                                Next = new myLinkedList <int>
                                {
                                    data = 1051,
                                }
                            }
                        }
                    }
                }
            };

            var obj = new CareerCupQnA();
            var res = obj.MergeSortedArray(number1, number2);

            while (res != null)
            {
                Console.WriteLine(res.data);
                res = res.Next;
            }
        }
Пример #24
0
        public static void SwapParkingLots()
        {
            var obj   = new CareerCupQnA();
            var input = new List <EmployeeParkingInfo>
            {
                new EmployeeParkingInfo
                {
                    EmployeeName     = "A",
                    FromBuildingName = "1",
                    ToBuildingName   = "2",
                },
                new EmployeeParkingInfo
                {
                    EmployeeName     = "B",
                    FromBuildingName = "3",
                    ToBuildingName   = "2",
                },
                new EmployeeParkingInfo
                {
                    EmployeeName     = "C",
                    FromBuildingName = "1",
                    ToBuildingName   = "4",
                },
                new EmployeeParkingInfo
                {
                    EmployeeName     = "D",
                    FromBuildingName = "2",
                    ToBuildingName   = "1",
                },
                new EmployeeParkingInfo
                {
                    EmployeeName     = "F",
                    FromBuildingName = "5",
                    ToBuildingName   = "2",
                },
                new EmployeeParkingInfo
                {
                    EmployeeName     = "G",
                    FromBuildingName = "9",
                    ToBuildingName   = "2",
                }
            };
            var output = obj.SwapParkingLots(input);

            foreach (var s in output)
            {
                Console.WriteLine(s);
            }
        }
Пример #25
0
        static void Adding2LinkedList()
        {
            var obj = new CareerCupQnA();
            var one = new LinkedList <int>();

            one.AddLast(1);
            one.AddLast(2);
            one.AddLast(3);
            one.AddLast(7);

            var sec = new LinkedList <int>();

            sec.AddLast(2);
            sec.AddLast(9);
            obj.Adding2LinkedList(one.First, sec.First);
        }
Пример #26
0
        /************************************************************************************************************/

        public static void CallingFindingConsecutive()
        {
            Console.WriteLine("CallingFindingConsecutive Starts");
            var obj = new CareerCupQnA();

            //obj.FindConsecutiveRepetitive("ffgggtvshjsdhjfffffffffhvjbjchaaaaaaaaaaaaaaaru");
            obj.FindConsecutiveRepetitiveWithNoDict("ffgggtvshjsdhjfffffffffhvjbjchaaaaaaaaaaaaaaaru");

            //obj.FindConsecutiveRepetitive("ffgggtvshjsdhjfffffffffhvjbjchru");
            obj.FindConsecutiveRepetitiveWithNoDict("ffgggtvshjsdhjfffffffffhvjbjchru");

            //obj.FindConsecutiveRepetitive("abcddddef");
            obj.FindConsecutiveRepetitiveWithNoDict("abcddddef");

            Console.WriteLine("CallingFindingConsecutive Ends");
        }
Пример #27
0
        public static void maxConsecutiveSequenceOfBTree()
        {
            var obj  = new CareerCupQnA();
            var tree = new BinaryTree <int>
            {
                Node = 90,
                Left = new BinaryTree <int>
                {
                    Node = 1,
                    Left = new BinaryTree <int>
                    {
                        Node = 22,
                        Left = new BinaryTree <int>
                        {
                            Node = 5,
                            Left = new BinaryTree <int>
                            {
                                Node = 99,
                            },
                            Right = new BinaryTree <int>
                            {
                                Node = 100
                            }
                        },
                        Right = new BinaryTree <int>
                        {
                            Node = 4
                        }
                    },
                    Right = new BinaryTree <int>
                    {
                        Node = 67,
                        Left = new BinaryTree <int>
                        {
                            Node = 68
                        }
                    }
                },
                Right = new BinaryTree <int>
                {
                    Node = 66
                }
            };

            obj.maxConsecutiveSequenceOfBTree(tree);
            Console.WriteLine(obj.getMaxSize());
        }
Пример #28
0
        public static void FindContradictionOfEquations()
        {
            var obj = new CareerCupQnA();

            obj.FindContradictionOfEquations(new List <List <string> >
            {
                new List <string>
                {
                    "A=B",
                    "B=D",
                    "C=D",
                    "F=G",
                    "E=H",
                    "H=C",
                }
            });
        }
Пример #29
0
        public static void MergeAndRemoveDuplicatesInLinkedLists()
        {
            var obj   = new CareerCupQnA();
            var input = new List <List <int> >
            {
                new List <int> {
                    1, 2, 3, 4
                },
                new List <int> {
                    2, 5, 6, 7
                },
                new List <int> {
                    6, 9, 10, 11
                },
            };

            obj.MergeAndRemoveDuplicatesInLinkedLists(input);
        }
Пример #30
0
        public static void FindTheBiggestCross()
        {
            var obj = new CareerCupQnA();

            int[,] array2D = new int[, ] {
                { 1, 1, 1, 1, 1 },
                { 0, 0, 1, 1, 1 },
                { 1, 1, 1, 1, 1 },
                { 0, 0, 1, 0, 0 },
                { 1, 1, 1, 1, 1 },
            };
            Console.WriteLine(obj.FindTheBiggestCross(array2D, 5, 5));

            //foreach (var str in res)
            //{
            //    Console.WriteLine(str);
            //}
        }