Given a sorted array and a target value, determine whether the target is a majority element — that is, whether it appears more than n/2 times (n being the array length). Use binary search to find its first and last positions. Return true or false. Input: '[arr], target'.
Input: '[arr], target'.
Output: Boolean — true or false.
Input: [2,4,5,5,5,5,5,6,6], 5
Output: true
Explanation: 5 appears 5 times out of 9.Input: [10,100,101,101], 101
Output: false
Explanation: 101 appears 2 times of 4, not a majority.Input: [1], 1
Output: true
Explanation: Single matching element.1<=n<=1000sorted ascending