1150. Check If a Number Is Majority Element in a Sorted Array

Problem

Intuition

If the number has to be majority, it should at least occur more than nums.length/2 times in the array.

Since we found the first position, if we take half the length of input array and add it to the the first position, it gives the minimum position at which target should be present to be called as a majority number

Check if the plusNBy2Idx is in range and check if the number present at plusNBy2Idx is the target

Time Complexity

Space Complexity

Solution

Last updated