using Newtonsoft.Json.Linq;
using System.Collections;
using System.Collections.Generic;
public int[] mostCommonElements(int[] elements){
List<int> lstElements = elements.OfType<int>().ToList();
var grpElements = lstElements
.OrderByDescending (item => item.Count())
.Select(g => new { selectedval = g.Key, Count = g.Count() });
int selectedCnt=grpElements.ToArray()[0].Count;
List<int> retElements = grpElements
.Where(item => item.Count == selectedCnt)
.Select(item => item.selectedval )
foreach (int ele in retElements)
return retElements.ToArray();
public ArrayList positiveDivisors(int num){
ArrayList resList = new ArrayList();
public double triangleArea(int x,int y,int z){
if(Math.Pow(x, 2) + Math.Pow(y, 2)== Math.Pow(z, 2) || Math.Pow(z, 2) + Math.Pow(x, 2)== Math.Pow(y, 2) || Math.Pow(y, 2)+ Math.Pow(z, 2)== Math.Pow(x, 2) )
double area = Math.Sqrt(s*(s-x)*(s-y)*(s-z));
throw new InvalidTriangleException("Not Valid Inputs for Triangle");
catch(OverflowException ex){
throw new InvalidTriangleException(ex.Message);
private int[] inn1 ={5, 4, 3, 2, 4, 5, 1, 6, 1, 2, 5, 4};
private int[] inn2 ={1, 2, 3, 4, 5, 1, 6, 7};
private int[] inn3 ={1, 2, 3, 4, 5, 6, 7};
public void Requirement4Test(int[] inn, int[] res)
CShartTest cs=new CShartTest();
Assert.AreEqual( res,cs.mostCommonElements(inn));
public void Requirement2Test(int inn, int[] res)
CShartTest cs=new CShartTest();
Assert.AreEqual( res,cs.positiveDivisors(inn) );
public void Requirement3Test(int inn, int res)
CShartTest cs=new CShartTest();
Assert.AreEqual( res,cs.positiveDivisors(inn) );
public static void Main()
CShartTest cs=new CShartTest();
Console.WriteLine("Requirement 4 starts Test 1");
int[] m ={5, 4, 3, 2, 4, 5, 1, 6, 1, 2, 5, 4};
int[] mc= cs.mostCommonElements(m);
Console.WriteLine("Requirement 4 Test 2");
int[] m2 ={1, 2, 3, 4, 5, 1, 6, 7};
int[] mc2= cs.mostCommonElements(m2);
Console.WriteLine("Requirement 4 Test 3");
int[] m3 ={1, 2, 3, 4, 5, 6, 7};
int[] mc3= cs.mostCommonElements(m3);
Console.WriteLine(cs.positiveDivisors(60));
Console.WriteLine(cs.triangleArea(3,4,5));
public class InvalidTriangleException: Exception
public InvalidTriangleException()
public InvalidTriangleException(string message)