Example #1
0
        public void TestGetUniqueArrayLengthForSameArray()
        {
            int[] input = new int[] { 0, 0, 0, 0 };

            RemoveDuplicate removeDuplicate = new RemoveDuplicate();
            var             result          = removeDuplicate.RemoveDuplicates(input);

            Assert.AreEqual(1, result);
        }
Example #2
0
        public void TestGetUniqueArrayLengthForDistinctElement()
        {
            int[] input = new int[] { 0, 1, 2, 3, 4 };

            RemoveDuplicate removeDuplicate = new RemoveDuplicate();
            var             result          = removeDuplicate.RemoveDuplicates(input);

            Assert.AreEqual(5, result);
        }
Example #3
0
        static void Main(string[] args)
        {
            GradeAverage gradeAverage = new GradeAverage();

            gradeAverage.DisplayResults();
            Console.WriteLine("\n ================================");
            RemoveDuplicate removeDuplicate = new RemoveDuplicate();

            removeDuplicate.DisplayResults();
            Console.ReadLine();
        }
Example #4
0
            public static void Main()
            {
                RemoveDuplicate <int> sList = new RemoveDuplicate <int>();

                sList.addNode(1);
                sList.addNode(2);
                sList.addNode(3);
                sList.addNode(2);
                sList.addNode(2);
                sList.addNode(4);
                sList.addNode(1);

                Console.WriteLine("Originals list: ");
                sList.display();

                sList.removeDuplicate();

                Console.WriteLine("List after removing duplicates: ");
                sList.display();
            }
Example #5
0
        public static void SelectedOption(int option)
        {
            switch (option)
            {
            case 1:
                List <string> input = new List <string> {
                    "apple", "apple", "ball", "cup", "mango", "cup", "banana"
                };
                RemoveDuplicate.DistinctValues(input);
                break;

            case 2:
                PrimeNumber.PrimeNum();
                break;

            case 3:
                FizzBuzzChallenge.FizzBuzz();
                break;
            }
        }
        public static string Find(string inputStr)
        {
            string[]      strList = inputStr.Split(' ');
            StringBuilder sb      = new StringBuilder();

            Dictionary <string, List <string> > strDic = new Dictionary <string, List <string> >();

            foreach (var s in strList)
            {
                var strwithoutdup = RemoveDuplicate.RemoveDuplicateFromString(s).ToLower();
                if (strDic.ContainsKey(SortString.Sort(strwithoutdup)))
                {
                    strDic[SortString.Sort(strwithoutdup)].Add(s);
                }
                else
                {
                    strDic.Add(SortString.Sort(strwithoutdup), new List <string> {
                        s
                    });
                }
            }

            foreach (var dic in strDic)
            {
                if (dic.Value.Count > 1)
                {
                    foreach (var s in dic.Value)
                    {
                        sb.Append(s);
                        sb.Append("  ");
                        sb.Append("\n");
                    }
                }
            }

            return(sb.ToString());
        }
Example #7
0
        public void Init()
        {
            _data = new RemoveDuplicate(new DSNode <int>()
            {
                Data = 1,
                Next = new DSNode <int>()
                {
                    Data = 2,
                    Next = new DSNode <int>()
                    {
                        Data = 3,
                        Next = new DSNode <int>()
                        {
                            Data = 4,
                            Next = new DSNode <int>()
                            {
                                Data = 5,
                                Next = new DSNode <int>()
                                {
                                    Data = 5,
                                    Next = new DSNode <int>()
                                    {
                                        Data = 6,
                                        Next = new DSNode <int>()
                                        {
                                            Data = 6
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            });

            _unsortedData = new RemoveDuplicate(new DSNode <int>()
            {
                Data = 3,
                Next = new DSNode <int>()
                {
                    Data = 2,
                    Next = new DSNode <int>()
                    {
                        Data = 3,
                        Next = new DSNode <int>()
                        {
                            Data = 1,
                            Next = new DSNode <int>()
                            {
                                Data = 2,
                                Next = new DSNode <int>()
                                {
                                    Data = 5,
                                    Next = new DSNode <int>()
                                    {
                                        Data = 6,
                                        Next = new DSNode <int>()
                                        {
                                            Data = 6
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            });
        }