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); }
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); }
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)); }
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); } }
static void SumPath() { var obj = new CareerCupQnA(); var treeO = new TreesNGraph(); obj.SumPath(treeO.PopulateBinarySTree(), 28); }
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); }
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("-----------------------------------------------------------------------"); }
public static void StudyRecursive() { var obj = new CareerCupQnA(); var v = 10; obj.StudyRecursive(v); Console.WriteLine("Answer :" + v); }
public static void FindItsParent() { var obj = new CareerCupQnA(); var obj1 = new TreesNGraph(); obj.FindItsParent(obj1.PopulateBinaryTree(), 5, 0); }
static void NonAdjacentSum() { var obj = new CareerCupQnA(); Console.WriteLine(obj.NonAdjacentSum(new List <int> { 3, 2, 5, 10, 7 })); }
static void FormatArray() { var obj = new CareerCupQnA(); obj.FormatArray(new List <int> { 1, 1, 2, 2, 2, 3, 4, 4, 4, 4, 5 }, 1); }
public static void MaxTimeOfTask() { var obj = new CareerCupQnA(); obj.MaxTimeOfTask(new List <int> { 5, 1, 3, 2, 5 }, 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 }); }
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); }
static void CheckBST() { var obj = new CareerCupQnA(); var obj1 = new TreesNGraph(); var binaryTree = obj1.PopulateBinarySTree(); Console.WriteLine("InOrder Starts"); Console.WriteLine(obj.CheckBST(binaryTree)); }
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); }
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()); }
//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); }
static void RemoveDuplicatesInStringRecursion() { var s = "aaabbbbccccddef"; var obj = new CareerCupQnA(); var res = obj.RemoveDuplicatesInStringRecursion(s, 0); Console.WriteLine(res); }
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())); }
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"); }
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); } }
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; } }
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); } }
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); }
/************************************************************************************************************/ 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"); }
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()); }
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", } }); }
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); }
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); //} }