target
in nums
. Store this index in firstIndex
.firstIndex + nums.length / 2
is within the bounds of the array.nums[firstIndex + nums.length / 2]
is equal to target
.target
, return true
, indicating that target
is a majority element.false
.