Find element in a sorted array whose frequency is greater than or equal to n / 2. | Javascript code to find majority element in a sorted array ; driver code
function findMajority ( arr , n ) { return arr [ Math . floor ( n / 2 ) ] ; } let arr = [ 1 , 2 , 2 , 3 ] ; let n = arr . length ; document . write ( findMajority ( arr , n ) ) ;