Find element in a sorted array whose frequency is greater than or equal to n / 2. | PHP code to find majority element in a sorted array ; Driver Code
< ? php function findMajority ( $ arr , $ n ) { return $ arr [ intval ( $ n / 2 ) ] ; } $ arr = array ( 1 , 2 , 2 , 3 ) ; $ n = count ( $ arr ) ; echo findMajority ( $ arr , $ n ) ; ? >