How does LeetCode find the numbers that appear more than half the times in the array
This article will explain in detail how LeetCode finds the numbers that appear in the array more than half of the times. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.
0x01, brief description of the problem
There is a number in the array that appears more than half the length of the array. Please find this number. You can assume that the array is not empty and that there are always many elements in a given array.
0x02, exampl
Example 1:
Input: [1,2,3,2,2,2,5,4,2] output: 2
Restrictions:
one